fix zero division error
This commit is contained in:
parent
27cac0efde
commit
626b2fb828
18
decoder.py
18
decoder.py
@ -238,14 +238,18 @@ def get_callsign(msg):
|
|||||||
return cs
|
return cs
|
||||||
|
|
||||||
|
|
||||||
def cprN(lat, isodd):
|
def cprN(lat, is_odd):
|
||||||
nl = cprNL(lat) - isodd
|
nl = cprNL(lat) - is_odd
|
||||||
return nl if nl > 1 else 1
|
return nl if nl > 1 else 1
|
||||||
|
|
||||||
|
|
||||||
def cprNL(lat):
|
def cprNL(lat):
|
||||||
nz = 60
|
try:
|
||||||
a = 1 - math.cos(math.pi * 2 / nz)
|
nz = 60
|
||||||
b = math.cos(math.pi / 180.0 * abs(lat)) ** 2
|
a = 1 - math.cos(math.pi * 2 / nz)
|
||||||
nl = 2 * math.pi / (math.acos(1 - a/b))
|
b = math.cos(math.pi / 180.0 * abs(lat)) ** 2
|
||||||
return int(nl)
|
nl = 2 * math.pi / (math.acos(1 - a/b))
|
||||||
|
return int(nl)
|
||||||
|
except:
|
||||||
|
# happens when latitude is +/-90 degree
|
||||||
|
return 1
|
||||||
|
Loading…
Reference in New Issue
Block a user