junzis / pyModeS

Python decoder for Mode S and ADS-B signals
GNU General Public License v3.0
546 stars 153 forks source link

Properly return None if altitude could not be decoded #162

Closed paulmadejong closed 9 months ago

paulmadejong commented 9 months ago

c_common.py: return -999999 (extremely low, physically impossible) altitude in case altitude is unknown or invalid, bds04.py: convert -999999 altitude to None to better signal an invalid/unknown decoded altitude to the user

xoolive commented 9 months ago

9999 is already invalid because altitude values are multiple of 25

paulmadejong commented 9 months ago

9999 is already invalid because altitude values are multiple of 25

That's definitely the case but requires the user to check for this and really understand the data (and format). Returning a None really signals a problem to the user.

If you just mean to leave the -9999 instead of -99999 I would totally agree but would appreciate the remaining logic to convert that to None to remain.

xoolive commented 9 months ago

Sure I just quickly commented (from the phone) about the value edit on the Cython side. It does make sense to switch to None on the Python side though

junzis commented 9 months ago

Hi both, the pr looks good to me and passed the tests. I don't mind if it is -9999 or -99999 or -999999 :smile: I am going to merge it, as it is quite straight forward.