Skip to content

Commit

Permalink
update NL() function in CPR decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
junzis committed Mar 3, 2020
1 parent a75d6fd commit ed18352
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 4 additions & 6 deletions pyModeS/decoder/c_common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from cpython cimport array
from cpython.bytes cimport PyBytes_GET_SIZE
from cpython.bytearray cimport PyByteArray_GET_SIZE

from libc.math cimport cos, acos, fabs, M_PI as pi, floor as c_floor
from libc.math cimport abs, cos, acos, fabs, M_PI as pi, floor as c_floor


cdef int char_to_int(unsigned char binstr):
Expand Down Expand Up @@ -231,13 +231,11 @@ cpdef int typecode(str msg):
cpdef int cprNL(double lat):
"""NL() function in CPR decoding."""

if lat == 0:
if abs(lat) <= 1e-08:
return 59

if lat == 87 or lat == -87:
elif abs(abs(lat) - 87) <= 1e-08 + 1e-05 * 87:
return 2

if lat > 87 or lat < -87:
elif lat > 87 or lat < -87:
return 1

cdef int nz = 15
Expand Down
8 changes: 3 additions & 5 deletions pyModeS/decoder/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,11 @@ def typecode(msg):
def cprNL(lat):
"""NL() function in CPR decoding."""

if lat == 0:
if np.isclose(lat, 0):
return 59

if lat == 87 or lat == -87:
elif np.isclose(abs(lat), 87):
return 2

if lat > 87 or lat < -87:
elif lat > 87 or lat < -87:
return 1

nz = 15
Expand Down

0 comments on commit ed18352

Please sign in to comment.