Fix a bug where some WWFF references had "-" for lat/lon/grid and Spothole did not deal with them well.

This commit is contained in:
Ian Renton
2026-01-18 07:40:51 +00:00
parent 4d344021c7
commit 522f90af97
3 changed files with 28 additions and 13 deletions

View File

@@ -416,7 +416,12 @@ class LookupHelper:
# Infer a grid locator from a callsign (using DXCC, probably very inaccurate) # Infer a grid locator from a callsign (using DXCC, probably very inaccurate)
def infer_grid_from_callsign_dxcc(self, call): def infer_grid_from_callsign_dxcc(self, call):
latlon = self.infer_latlon_from_callsign_dxcc(call) latlon = self.infer_latlon_from_callsign_dxcc(call)
return latlong_to_locator(latlon[0], latlon[1], 8) grid = None
try:
grid = latlong_to_locator(latlon[0], latlon[1], 8)
except:
logging.debug("Invalid lat/lon received for DXCC")
return grid
# Infer a mode from the frequency (in Hz) according to the band plan. Just a guess really. # Infer a mode from the frequency (in Hz) according to the band plan. Just a guess really.
def infer_mode_from_frequency(self, freq): def infer_mode_from_frequency(self, freq):

View File

@@ -73,9 +73,9 @@ def populate_sig_ref_info(sig_ref):
if row["reference"] == ref_id: if row["reference"] == ref_id:
sig_ref.name = row["name"] if "name" in row else None sig_ref.name = row["name"] if "name" in row else None
sig_ref.url = "https://wwff.co/directory/?showRef=" + ref_id sig_ref.url = "https://wwff.co/directory/?showRef=" + ref_id
sig_ref.grid = row["iaruLocator"] if "iaruLocator" in row else None sig_ref.grid = row["iaruLocator"] if "iaruLocator" in row and row["iaruLocator"] != "-" else None
sig_ref.latitude = float(row["latitude"]) if "latitude" in row else None sig_ref.latitude = float(row["latitude"]) if "latitude" in row and row["latitude"] != "-" else None
sig_ref.longitude = float(row["longitude"]) if "longitude" in row else None sig_ref.longitude = float(row["longitude"]) if "longitude" in row and row["longitude"] != "-" else None
break break
elif sig.upper() == "SIOTA": elif sig.upper() == "SIOTA":
siota_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv", siota_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv",
@@ -112,9 +112,12 @@ def populate_sig_ref_info(sig_ref):
if asset["code"] == ref_id: if asset["code"] == ref_id:
sig_ref.name = asset["name"] sig_ref.name = asset["name"]
sig_ref.url = "https://ontheair.nz/assets/ZLI_OT-030" + ref_id.replace("/", "_") sig_ref.url = "https://ontheair.nz/assets/ZLI_OT-030" + ref_id.replace("/", "_")
sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6) try:
sig_ref.latitude = asset["y"] sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6)
sig_ref.longitude = asset["x"] except:
logging.debug("Invalid lat/lon received for reference")
sig_ref.latitude = asset["y"]
sig_ref.longitude = asset["x"]
break break
elif sig.upper() == "BOTA": elif sig.upper() == "BOTA":
if not sig_ref.name: if not sig_ref.name:
@@ -124,9 +127,12 @@ def populate_sig_ref_info(sig_ref):
ll = wab_wai_square_to_lat_lon(ref_id) ll = wab_wai_square_to_lat_lon(ref_id)
if ll: if ll:
sig_ref.name = ref_id sig_ref.name = ref_id
sig_ref.grid = latlong_to_locator(ll[0], ll[1], 6) try:
sig_ref.latitude = ll[0] sig_ref.grid = latlong_to_locator(ll[0], ll[1], 6)
sig_ref.longitude = ll[1] sig_ref.latitude = ll[0]
sig_ref.longitude = ll[1]
except:
logging.debug("Invalid lat/lon received for reference")
except: except:
logging.warn("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".") logging.warn("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".")
return sig_ref return sig_ref

View File

@@ -284,9 +284,13 @@ 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:
ll = locator_to_latlong(self.dx_grid) try:
self.dx_latitude = ll[0] print(json.dumps(self))
self.dx_longitude = ll[1] ll = locator_to_latlong(self.dx_grid)
self.dx_latitude = ll[0]
self.dx_longitude = ll[1]
except:
logging.debug("Invalid grid received for spot")
if self.dx_latitude and self.dx_longitude and not self.dx_grid: if self.dx_latitude and self.dx_longitude and not self.dx_grid:
try: try:
self.dx_grid = latlong_to_locator(self.dx_latitude, self.dx_longitude, 8) self.dx_grid = latlong_to_locator(self.dx_latitude, self.dx_longitude, 8)