optimisations in bds09

This commit is contained in:
Xavier Olive 2019-10-29 17:37:45 +01:00
parent 6144b88188
commit 13b283666a

View File

@ -5,6 +5,7 @@ cimport cython
from ..common cimport char_to_int, typecode, hex2bin, bin2int from ..common cimport char_to_int, typecode, hex2bin, bin2int
from libc.math cimport atan2, sqrt, pi, NAN as nan from libc.math cimport atan2, sqrt, pi, NAN as nan
@cython.cdivision(True)
def airborne_velocity(bytes msg, bint rtn_sources=False): def airborne_velocity(bytes msg, bint rtn_sources=False):
"""Calculate the speed, track (or heading), and vertical rate """Calculate the speed, track (or heading), and vertical rate
@ -36,7 +37,7 @@ def airborne_velocity(bytes msg, bint rtn_sources=False):
if bin2int(mb[14:24]) == 0 or bin2int(mb[25:35]) == 0: if bin2int(mb[14:24]) == 0 or bin2int(mb[25:35]) == 0:
return None return None
cdef int v_ew_sign, v_ew, v_ns_sign, v_ns cdef int v_ew_sign, v_ew, v_ns_sign, v_ns, v_we, v_sn
cdef double spd, trk, trk_or_hdg, hdg cdef double spd, trk, trk_or_hdg, hdg
if subtype in (1, 2): if subtype in (1, 2):
@ -87,8 +88,8 @@ def airborne_velocity(bytes msg, bint rtn_sources=False):
dir_type = "mag_north" dir_type = "mag_north"
vr_source = "GNSS" if mb[35] == 48 else "Baro" # "0" vr_source = "GNSS" if mb[35] == 48 else "Baro" # "0"
vr_sign = -1 if mb[36] == 49 else 1 # "1" cdef int vr_sign = -1 if mb[36] == 49 else 1 # "1"
vr = bin2int(mb[37:46]) cdef int vr = bin2int(mb[37:46])
rocd = None if vr == 0 else int(vr_sign * (vr - 1) * 64) rocd = None if vr == 0 else int(vr_sign * (vr - 1) * 64)
if rtn_sources: if rtn_sources:
@ -96,7 +97,6 @@ def airborne_velocity(bytes msg, bint rtn_sources=False):
else: else:
return int(spd), trk_or_hdg, rocd, tag return int(spd), trk_or_hdg, rocd, tag
def altitude_diff(bytes msg): def altitude_diff(bytes msg):
"""Decode the differece between GNSS and barometric altitude """Decode the differece between GNSS and barometric altitude