Merge branch 'master' of github.com:junzis/pyModeS

This commit is contained in:
Junzi Sun
2020-05-04 01:09:40 +02:00
2 changed files with 46 additions and 41 deletions

View File

@@ -43,15 +43,19 @@ def typecode(msg):
def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
"""Decode position from a pair of even and odd position message.
"""Decode surface or airborne position from a pair of even and odd
position messages.
Works with both airborne and surface position messages.
Note, that to decode surface position using the position message pair,
the reference position has to be provided.
Args:
msg0 (string): even message (28 hexdigits)
msg1 (string): odd message (28 hexdigits)
t0 (int): timestamps for the even message
t1 (int): timestamps for the odd message
lat_ref (float): latitude of reference position
lon_ref (float): longitude of reference position
Returns:
(float, float): (latitude, longitude) of the aircraft
@@ -61,11 +65,10 @@ def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
tc1 = typecode(msg1)
if 5 <= tc0 <= 8 and 5 <= tc1 <= 8:
if (not lat_ref) or (not lon_ref):
if lat_ref is None or lon_ref is None:
raise RuntimeError(
"Surface position encountered, a reference \
position lat/lon required. Location of \
receiver can be used."
"Surface position encountered, a reference position"
" lat/lon required. Location of receiver can be used."
)
else:
return surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref)
@@ -79,7 +82,7 @@ def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
return airborne_position(msg0, msg1, t0, t1)
else:
raise RuntimeError("incorrect or inconsistent message types")
raise RuntimeError("Incorrect or inconsistent message types")
def position_with_ref(msg, lat_ref, lon_ref):