From 73569e62cc041ec8fe601e9e0056d2a41b374742 Mon Sep 17 00:00:00 2001 From: Diego Garro Molina <51692835+diegogarromolina@users.noreply.github.com> Date: Mon, 28 Sep 2020 21:26:59 -0600 Subject: [PATCH] Fix Haversine formula in position class (Datatypes.py) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The correct formula has sin²(anlge). --- metar/Datatypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metar/Datatypes.py b/metar/Datatypes.py index c1ba23f1..201f6245 100644 --- a/metar/Datatypes.py +++ b/metar/Datatypes.py @@ -480,8 +480,8 @@ def getdistance(self, position2): long1 = self.longitude lat2 = position2.latitude long2 = position2.longitude - a = sin(0.5(lat2 - lat1)) + cos(lat1) * cos(lat2) * sin( - 0.5 * (long2 - long1) ** 2 + a = (sin(0.5(lat2 - lat1))) ** 2 + cos(lat1) * cos(lat2) * (sin( + 0.5 * (long2 - long1)) ** 2 ) c = 2.0 * atan(sqrt(a) * sqrt(1.0 - a)) d = distance(earth_radius * c, "M")