minor fix in surface speed calculation

This commit is contained in:
Junzi Sun 2020-07-29 00:53:05 +02:00
parent 0d7f628f3c
commit 1f15a953e3
2 changed files with 6 additions and 8 deletions

View File

@ -168,13 +168,11 @@ def surface_velocity(msg, source=False):
elif mov == 124: elif mov == 124:
spd = 175 spd = 175
else: else:
movs = [2, 9, 13, 39, 94, 109, 124] mov_lb = [2, 9, 13, 39, 94, 109, 124]
kts = [0.125, 1, 2, 15, 70, 100, 175] kts_lb = [0.125, 1, 2, 15, 70, 100, 175]
i = next(m[0] for m in enumerate(movs) if m[1] > mov) step = [0.125, 0.25, 0.5, 1, 2, 5]
step = (kts[i] - kts[i - 1]) * 1.0 / (movs[i] - movs[i - 1]) i = next(m[0] for m in enumerate(mov_lb) if m[1] > mov)
spd = kts[i - 1] + (mov - movs[i - 1]) * step spd = kts_lb[i - 1] + (mov - mov_lb[i - 1]) * step[i - 1]
spd = round(spd, 2)
if source: if source:
return spd, trk, 0, "GS", "TRUE_NORTH", None return spd, trk, 0, "GS", "TRUE_NORTH", None
else: else:

View File

@ -76,7 +76,7 @@ def test_adsb_velocity():
vgs_surface = adsb.velocity("8FC8200A3AB8F5F893096B000000") vgs_surface = adsb.velocity("8FC8200A3AB8F5F893096B000000")
assert vgs == (159, 182.88, -832, "GS") assert vgs == (159, 182.88, -832, "GS")
assert vas == (375, 243.98, -2304, "TAS") assert vas == (375, 243.98, -2304, "TAS")
assert vgs_surface == (19.0, 42.2, 0, "GS") assert vgs_surface == (19, 42.2, 0, "GS")
assert adsb.altitude_diff("8D485020994409940838175B284F") == 550 assert adsb.altitude_diff("8D485020994409940838175B284F") == 550