diff --git a/core/lookup_helper.py b/core/lookup_helper.py index 31bcc72..1ecb8f6 100644 --- a/core/lookup_helper.py +++ b/core/lookup_helper.py @@ -416,7 +416,12 @@ class LookupHelper: # Infer a grid locator from a callsign (using DXCC, probably very inaccurate) def infer_grid_from_callsign_dxcc(self, 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. def infer_mode_from_frequency(self, freq): diff --git a/core/sig_utils.py b/core/sig_utils.py index d712741..40b8432 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -73,9 +73,9 @@ def populate_sig_ref_info(sig_ref): if row["reference"] == ref_id: sig_ref.name = row["name"] if "name" in row else None sig_ref.url = "https://wwff.co/directory/?showRef=" + ref_id - sig_ref.grid = row["iaruLocator"] if "iaruLocator" in row else None - sig_ref.latitude = float(row["latitude"]) if "latitude" in row else None - sig_ref.longitude = float(row["longitude"]) if "longitude" 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 and row["latitude"] != "-" else None + sig_ref.longitude = float(row["longitude"]) if "longitude" in row and row["longitude"] != "-" else None break elif sig.upper() == "SIOTA": 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: sig_ref.name = asset["name"] sig_ref.url = "https://ontheair.nz/assets/ZLI_OT-030" + ref_id.replace("/", "_") - sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6) - sig_ref.latitude = asset["y"] - sig_ref.longitude = asset["x"] + try: + sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6) + except: + logging.debug("Invalid lat/lon received for reference") + sig_ref.latitude = asset["y"] + sig_ref.longitude = asset["x"] break elif sig.upper() == "BOTA": 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) if ll: sig_ref.name = ref_id - sig_ref.grid = latlong_to_locator(ll[0], ll[1], 6) - sig_ref.latitude = ll[0] - sig_ref.longitude = ll[1] + try: + sig_ref.grid = latlong_to_locator(ll[0], ll[1], 6) + sig_ref.latitude = ll[0] + sig_ref.longitude = ll[1] + except: + logging.debug("Invalid lat/lon received for reference") except: logging.warn("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".") return sig_ref diff --git a/data/spot.py b/data/spot.py index 00de115..cfafdfa 100644 --- a/data/spot.py +++ b/data/spot.py @@ -284,9 +284,13 @@ class Spot: # DX Grid to lat/lon and vice versa in case one is missing if self.dx_grid and not self.dx_latitude: - ll = locator_to_latlong(self.dx_grid) - self.dx_latitude = ll[0] - self.dx_longitude = ll[1] + try: + print(json.dumps(self)) + 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: try: self.dx_grid = latlong_to_locator(self.dx_latitude, self.dx_longitude, 8)