Fix surface positions for negative longitude

This commit is contained in:
Richard Janssen 2019-09-03 12:15:34 +02:00
parent 458b02028d
commit 0ea2cf7ade
3 changed files with 28 additions and 0 deletions

10
.gitignore vendored
View File

@ -58,3 +58,13 @@ target/
# PyCharm # PyCharm
.idea/ .idea/
# Environments
.env
.venv
.virtualenvs
env/
venv/
ENV/
env.bak/
venv.bak/

View File

@ -89,6 +89,9 @@ def surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref):
# four possible longitude solutions # four possible longitude solutions
lons = [lon, lon + 90.0, lon + 180.0, lon + 270.0] lons = [lon, lon + 90.0, lon + 180.0, lon + 270.0]
# make sure lons are between -180 and 180
lons = [(l + 180) % 360 - 180 for l in lons]
# the closest solution to receiver is the correct one # the closest solution to receiver is the correct one
dls = [abs(lon_ref - l) for l in lons] dls = [abs(lon_ref - l) for l in lons]
imin = min(range(4), key=dls.__getitem__) imin = min(range(4), key=dls.__getitem__)

View File

@ -18,3 +18,18 @@ def test_bds_is50or60():
assert bds.is50or60("A0001838201584F23468207CDFA5", 0, 0, 0) == None assert bds.is50or60("A0001838201584F23468207CDFA5", 0, 0, 0) == None
assert bds.is50or60("A0000000FFDA9517000464000000", 182, 237, 1250) == 'BDS50' assert bds.is50or60("A0000000FFDA9517000464000000", 182, 237, 1250) == 'BDS50'
assert bds.is50or60("A0000000919A5927E23444000000", 413, 54, 18700) == 'BDS60' assert bds.is50or60("A0000000919A5927E23444000000", 413, 54, 18700) == 'BDS60'
def test_surface_position():
msg0 = "8FE48C033A9FA184B934E744C6FD"
msg1 = "8FE48C033A9FA68F7C3D39B1C2F0"
t0 = 1565608663102
t1 = 1565608666214
lat_ref = -23.4265448
lon_ref = -46.4816258
lat, lon = bds.bds06.surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref)
assert abs(lon_ref - lon) < 0.05