More tweaks for string lat/lons

This commit is contained in:
Ian Renton
2026-04-03 15:32:48 +01:00
parent 9cfc3051a5
commit 8d2fcc69b0
10 changed files with 30 additions and 26 deletions

View File

@@ -337,11 +337,15 @@ class Spot:
self.dx_grid = lookup_helper.infer_grid_from_callsign_dxcc(self.dx_call)
self.dx_location_source = "DXCC"
# It looks like we can sometimes get a string into lat/lon, so reject that before we try looking anything up
# It looks like we can sometimes get a string into lat/lon, so try to parse as float, reject if not valid
if isinstance(self.dx_latitude, str) or isinstance(self.dx_longitude, str):
logging.warning("Received strings in lat/lon (" + str(self.dx_latitude) + ", " + str(self.dx_longitude) + ") for call " + self.dx_call + ", rejecting it")
self.dx_latitude = None
self.dx_longitude = None
try:
self.dx_latitude = float(self.dx_latitude)
self.dx_longitude = float(self.dx_longitude)
except (TypeError, ValueError):
logging.warning("Received non-numeric strings in lat/lon (" + str(self.dx_latitude) + ", " + str(self.dx_longitude) + ") for call " + self.dx_call + ", rejecting it")
self.dx_latitude = None
self.dx_longitude = None
# CQ and ITU zone lookup, preferably from location but failing that, from callsign
if not self.dx_cq_zone: