Support LLOTA #98

This commit is contained in:
Ian Renton
2026-01-18 12:10:16 +00:00
parent 65957b4c01
commit 0babf0a6be
8 changed files with 71 additions and 8 deletions

View File

@@ -28,6 +28,8 @@ SIGS = [
SIG(name="WOTA", description="Wainwrights on the Air", ref_regex=r"[A-Z]{3}-[0-9]{2}"),
SIG(name="BOTA", description="Beaches on the Air"),
SIG(name="KRMNPA", description="Keith Roget Memorial National Parks Award"),
SIG(name="LLOTA", description="Lagos y Lagunas on the Air", ref_regex=r"[A-Z]{2}\-\d{4}"),
SIG(name="WWTOTA", description="Towers on the Air", ref_regex=r"[A-Z]{2}R\-\d{4}"),
SIG(name="WAB", description="Worked All Britain", ref_regex=r"[A-Z]{1,2}[0-9]{2}"),
SIG(name="WAI", description="Worked All Ireland", ref_regex=r"[A-Z][0-9]{2}"),
SIG(name="TOTA", description="Toilets on the Air", ref_regex=r"T\-[0-9]{2}")

View File

@@ -1,7 +1,7 @@
import csv
import logging
from pyhamtools.locator import latlong_to_locator
from pyhamtools.locator import latlong_to_locator, locator_to_latlong
from core.cache_utils import SEMI_STATIC_URL_DATA_CACHE
from core.constants import SIGS, HTTP_HEADERS
@@ -21,7 +21,7 @@ def get_ref_regex_for_sig(sig):
# Note there is currently no support for KRMNPA location lookup, see issue #61.
def populate_sig_ref_info(sig_ref):
if sig_ref.sig is None or sig_ref.id is None:
logging.warn("Failed to look up sig_ref info, sig or id were not set.")
logging.warning("Failed to look up sig_ref info, sig or id were not set.")
sig = sig_ref.sig
ref_id = sig_ref.id
@@ -123,6 +123,18 @@ def populate_sig_ref_info(sig_ref):
if not sig_ref.name:
sig_ref.name = sig_ref.id
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-")
elif sig.upper() == "LLOTA":
data = SEMI_STATIC_URL_DATA_CACHE.get("https://llota.app/api/public/references", headers=HTTP_HEADERS).json()
if data:
for ref in data:
if ref["reference_code"] == ref_id:
sig_ref.name = ref["name"]
sig_ref.url = "https://llota.app/list/ref/" + ref_id
sig_ref.grid = ref["grid_locator"]
ll = locator_to_latlong(sig_ref.grid)
sig_ref.latitude = ll[0]
sig_ref.longitude = ll[1]
break
elif sig.upper() == "WAB" or sig.upper() == "WAI":
ll = wab_wai_square_to_lat_lon(ref_id)
if ll:
@@ -134,7 +146,7 @@ def populate_sig_ref_info(sig_ref):
except:
logging.debug("Invalid lat/lon received for reference")
except:
logging.warn("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".")
logging.warning("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".")
return sig_ref