handle errors when gps coordinates are out of range
This commit is contained in:
parent
460bada88f
commit
0b64b4ac97
@ -2,6 +2,9 @@ from owrx.config import Config
|
||||
from owrx.locator import Locator
|
||||
from owrx.property import PropertyFilter
|
||||
from owrx.property.filter import ByPropertyName
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ReceiverDetails(PropertyFilter):
|
||||
@ -20,5 +23,8 @@ class ReceiverDetails(PropertyFilter):
|
||||
|
||||
def __dict__(self):
|
||||
receiver_info = super().__dict__()
|
||||
receiver_info["locator"] = Locator.fromCoordinates(receiver_info["receiver_gps"])
|
||||
try:
|
||||
receiver_info["locator"] = Locator.fromCoordinates(receiver_info["receiver_gps"])
|
||||
except ValueError as e:
|
||||
logger.error("invalid receiver location, check in settings: %s", str(e))
|
||||
return receiver_info
|
||||
|
@ -5,6 +5,11 @@ class Locator(object):
|
||||
lat = coordinates["lat"]
|
||||
lon = coordinates["lon"]
|
||||
|
||||
if not -90 < lat < 90:
|
||||
raise ValueError("invalid latitude: {}".format(lat))
|
||||
if not -180 < lon < 180:
|
||||
raise ValueError("invalid longitude: {}".format(lon))
|
||||
|
||||
lon = lon + 180
|
||||
lat = lat + 90
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user