Extra protection against string lat/longs creeping into the system

This commit is contained in:
Ian Renton
2026-02-14 07:57:36 +00:00
parent 6e7ffd626e
commit e6c9bb1853
2 changed files with 5 additions and 6 deletions

View File

@@ -364,10 +364,10 @@ class LookupHelper:
def infer_latlon_from_callsign_online_lookup(self, call): def infer_latlon_from_callsign_online_lookup(self, call):
data = self.get_qrz_data_for_callsign(call) data = self.get_qrz_data_for_callsign(call)
if data and "latitude" in data and "longitude" in data and (float(data["latitude"]) != 0 or float(data["longitude"]) != 0) and -89.9 < float(data["latitude"]) < 89.9: if data and "latitude" in data and "longitude" in data and (float(data["latitude"]) != 0 or float(data["longitude"]) != 0) and -89.9 < float(data["latitude"]) < 89.9:
return [data["latitude"], data["longitude"]] return [float(data["latitude"]), float(data["longitude"])]
data = self.get_hamqth_data_for_callsign(call) data = self.get_hamqth_data_for_callsign(call)
if data and "latitude" in data and "longitude" in data and (float(data["latitude"]) != 0 or float(data["longitude"]) != 0) and -89.9 < float(data["latitude"]) < 89.9: if data and "latitude" in data and "longitude" in data and (float(data["latitude"]) != 0 or float(data["longitude"]) != 0) and -89.9 < float(data["latitude"]) < 89.9:
return [data["latitude"], data["longitude"]] return [float(data["latitude"]), float(data["longitude"])]
else: else:
return None return None
@@ -399,7 +399,7 @@ class LookupHelper:
try: try:
data = self.CALL_INFO_BASIC.get_lat_long(call) data = self.CALL_INFO_BASIC.get_lat_long(call)
if data and "latitude" in data and "longitude" in data: if data and "latitude" in data and "longitude" in data:
loc = [data["latitude"], data["longitude"]] loc = [float(data["latitude"]), float(data["longitude"])]
else: else:
loc = None loc = None
except KeyError: except KeyError:
@@ -408,11 +408,11 @@ class LookupHelper:
if not loc: if not loc:
data = self.get_clublog_xml_data_for_callsign(call) data = self.get_clublog_xml_data_for_callsign(call)
if data and "Lat" in data and "Lon" in data: if data and "Lat" in data and "Lon" in data:
loc = [data["Lat"], data["Lon"]] loc = [float(data["Lat"]), float(data["Lon"])]
if not loc: if not loc:
data = self.get_clublog_api_data_for_callsign(call) data = self.get_clublog_api_data_for_callsign(call)
if data and "Lat" in data and "Lon" in data: if data and "Lat" in data and "Lon" in data:
loc = [data["Lat"], data["Lon"]] loc = [float(data["Lat"]), float(data["Lon"])]
return loc return loc
# Infer a grid locator from a callsign (using DXCC, probably very inaccurate) # Infer a grid locator from a callsign (using DXCC, probably very inaccurate)

View File

@@ -282,7 +282,6 @@ class Spot:
# DX Grid to lat/lon and vice versa in case one is missing # DX Grid to lat/lon and vice versa in case one is missing
if self.dx_grid and not self.dx_latitude: if self.dx_grid and not self.dx_latitude:
try: try:
print(json.dumps(self))
ll = locator_to_latlong(self.dx_grid) ll = locator_to_latlong(self.dx_grid)
self.dx_latitude = ll[0] self.dx_latitude = ll[0]
self.dx_longitude = ll[1] self.dx_longitude = ll[1]