Merge pull request #48 from richardjanssen/master

Fix surface positions with negative longitude
This commit is contained in:
Junzi Sun 2019-09-03 22:14:41 +02:00 committed by GitHub
commit 03f81d120b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

6
.gitignore vendored
View File

@ -58,3 +58,9 @@ target/
# PyCharm
.idea/
# Environments
.env
.venv
env/
venv/

View File

@ -89,6 +89,9 @@ def surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref):
# four possible longitude solutions
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
dls = [abs(lon_ref - l) for l in lons]
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("A0000000FFDA9517000464000000", 182, 237, 1250) == 'BDS50'
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