From cadcbb1756e89f60d1b4ed9c48b451bcd6cc8438 Mon Sep 17 00:00:00 2001 From: junzis Date: Tue, 7 Mar 2017 10:22:53 +0100 Subject: [PATCH] major bug fix for function adsb.position_with_ref() --- pyModeS/adsb.py | 4 ++-- tests/test_adsb.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyModeS/adsb.py b/pyModeS/adsb.py index d5fa103..04aa9dc 100644 --- a/pyModeS/adsb.py +++ b/pyModeS/adsb.py @@ -274,10 +274,10 @@ def position_with_ref(msg, lat_ref, lon_ref): (float, float): (latitude, longitude) of the aircraft """ if 5 <= typecode(msg) <= 8: - return airborne_position_with_ref(msg, lat_ref, lon_ref) + return surface_position_with_ref(msg, lat_ref, lon_ref) elif 9 <= typecode(msg) <= 18: - return surface_position_with_ref(msg, lat_ref, lon_ref) + return airborne_position_with_ref(msg, lat_ref, lon_ref) else: raise RuntimeError("incorrect or inconsistant message types") diff --git a/tests/test_adsb.py b/tests/test_adsb.py index d64b4f1..50b1d61 100644 --- a/tests/test_adsb.py +++ b/tests/test_adsb.py @@ -22,6 +22,13 @@ def test_adsb_position(): assert pos == (49.81755, 6.08442) +def test_adsb_position_with_ref(): + pos = adsb.position_with_ref("8D40058B58C901375147EFD09357", 49.0, 6.0) + assert pos == (49.82410, 6.06785) + pos = adsb.position_with_ref("8FC8200A3AB8F5F893096B000000", -43.5, 172.5) + assert pos == (-43.48564, 172.53942) + + def test_adsb_airborne_position_with_ref(): pos = adsb.airborne_position_with_ref("8D40058B58C901375147EFD09357", 49.0, 6.0)