mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-03-15 12:24:29 +00:00
Support location lookup for LLOTA #97
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import csv
|
import csv
|
||||||
import logging
|
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.cache_utils import SEMI_STATIC_URL_DATA_CACHE
|
||||||
from core.constants import SIGS, HTTP_HEADERS
|
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.
|
# Note there is currently no support for KRMNPA location lookup, see issue #61.
|
||||||
def populate_sig_ref_info(sig_ref):
|
def populate_sig_ref_info(sig_ref):
|
||||||
if sig_ref.sig is None or sig_ref.id is None:
|
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
|
sig = sig_ref.sig
|
||||||
ref_id = sig_ref.id
|
ref_id = sig_ref.id
|
||||||
@@ -121,7 +121,17 @@ def populate_sig_ref_info(sig_ref):
|
|||||||
sig_ref.name = sig_ref.id
|
sig_ref.name = sig_ref.id
|
||||||
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-")
|
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-")
|
||||||
elif sig.upper() == "LLOTA":
|
elif sig.upper() == "LLOTA":
|
||||||
sig_ref.url = "https://llota.app/list/ref/" + ref_id
|
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() == "WWTOTA":
|
elif sig.upper() == "WWTOTA":
|
||||||
sig_ref.url = "https://wwtota.com/seznam/karta_rozhledny.php?ref=" + ref_id
|
sig_ref.url = "https://wwtota.com/seznam/karta_rozhledny.php?ref=" + ref_id
|
||||||
elif sig.upper() == "WAB" or sig.upper() == "WAI":
|
elif sig.upper() == "WAB" or sig.upper() == "WAI":
|
||||||
@@ -132,7 +142,7 @@ def populate_sig_ref_info(sig_ref):
|
|||||||
sig_ref.latitude = ll[0]
|
sig_ref.latitude = ll[0]
|
||||||
sig_ref.longitude = ll[1]
|
sig_ref.longitude = ll[1]
|
||||||
except:
|
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
|
return sig_ref
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class LLOTA(HTTPSpotProvider):
|
|||||||
comment = None
|
comment = None
|
||||||
spotter = None
|
spotter = None
|
||||||
if "history" in source_spot and len(source_spot["history"]) > 0:
|
if "history" in source_spot and len(source_spot["history"]) > 0:
|
||||||
comment = source_spot["history"][0]["comment"]
|
comment = source_spot["history"][-1]["comment"]
|
||||||
spotter = source_spot["history"][0]["spotter_callsign"]
|
spotter = source_spot["history"][-1]["spotter_callsign"]
|
||||||
# Convert to our spot format
|
# Convert to our spot format
|
||||||
spot = Spot(source=self.name,
|
spot = Spot(source=self.name,
|
||||||
source_id=source_spot["id"],
|
source_id=source_spot["id"],
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ from spotproviders.http_spot_provider import HTTPSpotProvider
|
|||||||
class POTA(HTTPSpotProvider):
|
class POTA(HTTPSpotProvider):
|
||||||
POLL_INTERVAL_SEC = 120
|
POLL_INTERVAL_SEC = 120
|
||||||
SPOTS_URL = "https://api.pota.app/spot/activator"
|
SPOTS_URL = "https://api.pota.app/spot/activator"
|
||||||
# Might need to look up extra park data
|
|
||||||
PARK_URL_ROOT = "https://api.pota.app/park/"
|
|
||||||
|
|
||||||
def __init__(self, provider_config):
|
def __init__(self, provider_config):
|
||||||
super().__init__(provider_config, self.SPOTS_URL, self.POLL_INTERVAL_SEC)
|
super().__init__(provider_config, self.SPOTS_URL, self.POLL_INTERVAL_SEC)
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ class SOTA(HTTPSpotProvider):
|
|||||||
# The actual data lookup all happens after parsing and checking the epoch.
|
# The actual data lookup all happens after parsing and checking the epoch.
|
||||||
EPOCH_URL = "https://api-db2.sota.org.uk/api/spots/epoch"
|
EPOCH_URL = "https://api-db2.sota.org.uk/api/spots/epoch"
|
||||||
SPOTS_URL = "https://api-db2.sota.org.uk/api/spots/60/all/all"
|
SPOTS_URL = "https://api-db2.sota.org.uk/api/spots/60/all/all"
|
||||||
# SOTA spots don't contain lat/lon, we need a separate lookup for that
|
|
||||||
SUMMIT_URL_ROOT = "https://api-db2.sota.org.uk/api/summits/"
|
|
||||||
|
|
||||||
def __init__(self, provider_config):
|
def __init__(self, provider_config):
|
||||||
super().__init__(provider_config, self.EPOCH_URL, self.POLL_INTERVAL_SEC)
|
super().__init__(provider_config, self.EPOCH_URL, self.POLL_INTERVAL_SEC)
|
||||||
|
|||||||
Reference in New Issue
Block a user