simplify N/NL functions in position decoding

This commit is contained in:
junzis 2016-07-08 17:44:18 +02:00
parent faf43134e5
commit 5518816b32

View File

@ -204,13 +204,13 @@ def airborne_position(msg0, msg1, t0, t1):
# compute ni, longitude index m, and longitude # compute ni, longitude index m, and longitude
if (t0 > t1): if (t0 > t1):
ni = _cprN(lat_even, 0) ni = max(_cprNL(lat_even), 1)
m = util.floor(cprlon_even * (_cprNL(lat_even)-1) - m = util.floor(cprlon_even * (_cprNL(lat_even)-1) -
cprlon_odd * _cprNL(lat_even) + 0.5) cprlon_odd * _cprNL(lat_even) + 0.5)
lon = (360.0 / ni) * (m % ni + cprlon_even) lon = (360.0 / ni) * (m % ni + cprlon_even)
lat = lat_even lat = lat_even
else: else:
ni = _cprN(lat_odd, 1) ni = max(_cprNL(lat_odd) - 1, 1)
m = util.floor(cprlon_even * (_cprNL(lat_odd)-1) - m = util.floor(cprlon_even * (_cprNL(lat_odd)-1) -
cprlon_odd * _cprNL(lat_odd) + 0.5) cprlon_odd * _cprNL(lat_odd) + 0.5)
lon = (360.0 / ni) * (m % ni + cprlon_odd) lon = (360.0 / ni) * (m % ni + cprlon_odd)
@ -227,11 +227,6 @@ def surface_position(msg0, msg1, t0, t1):
raise RuntimeError('suface position decoding to be implemented soon...') raise RuntimeError('suface position decoding to be implemented soon...')
def _cprN(lat, is_odd):
nl = _cprNL(lat) - is_odd
return nl if nl > 1 else 1
def _cprNL(lat): def _cprNL(lat):
try: try:
nz = 15 nz = 15