PositionReport: validate lat and long
added input validation for latitude and longitude
This commit is contained in:
parent
9cee09b7a8
commit
7d5dafa649
|
|
@ -5,8 +5,31 @@ from aprslib.util import latitude_to_ddm, longitude_to_ddm, comment_altitude
|
|||
|
||||
class PositionReport(APRSPacket):
|
||||
format = 'uncompressed'
|
||||
latitude = 0
|
||||
longitude = 0
|
||||
|
||||
_latitude = 0
|
||||
@property
|
||||
def latitude(self):
|
||||
return self._latitude
|
||||
|
||||
@latitude.setter
|
||||
def latitude(self, val):
|
||||
if -90 <= val <= 90:
|
||||
self._latitude = val
|
||||
else:
|
||||
raise ValueError("Latitude outside of -90 to 90 degree range")
|
||||
|
||||
_longitude = 0
|
||||
@property
|
||||
def longitude(self):
|
||||
return self._longitude
|
||||
|
||||
@longitude.setter
|
||||
def longitude(self, val):
|
||||
if -180 <= val <= 180:
|
||||
self._longitude = val
|
||||
else:
|
||||
raise ValueError("Longitude outside of -180 to 180 degree range")
|
||||
|
||||
symbol_table = '/'
|
||||
symbol = 'l'
|
||||
altitude = None
|
||||
|
|
|
|||
Loading…
Reference in New Issue