Support COTA. Closes #131

This commit is contained in:
Ian Renton
2026-08-31 21:17:55 +01:00
parent a33f02491d
commit b0caf697ae
13 changed files with 81 additions and 18 deletions
+3
View File
@@ -258,6 +258,9 @@ sig_ref_data_providers:
- class: "DTMBA" - class: "DTMBA"
enabled: true enabled: true
- class: "COTA"
enabled: true
- class: "Toilets" - class: "Toilets"
enabled: true enabled: true
+9
View File
@@ -233,6 +233,15 @@ SIGS = [
icon="fa-ship", icon="fa-ship",
region_flag="🇬🇧" region_flag="🇬🇧"
), ),
SIG(
name="COTA",
comment_names=["COTA"],
description="Castles on the Air",
ref_regex=r"[A-Z]{3}\-[0-9]{3,5}",
icon="fa-chess-rook",
region_flag="🇩🇪",
refs_globally_unique=False
),
SIG( SIG(
name="Toilets", name="Toilets",
comment_names=[], comment_names=[],
+2 -2
View File
@@ -31,10 +31,10 @@ def infer_mode_from_comment(comment):
"""Infer a mode from the comment""" """Infer a mode from the comment"""
for mode in ALL_MODES: for mode in ALL_MODES:
if re.match(r"(^|\W)" + mode + r"(^|\W)", comment, re.IGNORECASE): if re.match(r"(^|\W)" + mode + r"($|\W)", comment, re.IGNORECASE):
return mode return mode
for mode in MODE_ALIASES: for mode in MODE_ALIASES:
if re.match(r"(^|\W)" + mode + r"(^|\W)", comment, re.IGNORECASE): if re.match(r"(^|\W)" + mode + r"($|\W)", comment, re.IGNORECASE):
return MODE_ALIASES[mode] return MODE_ALIASES[mode]
return None return None
+1 -1
View File
@@ -270,7 +270,7 @@ class Spot:
sig = self.sig_refs[0].sig.upper() sig = self.sig_refs[0].sig.upper()
regex = get_ref_regex_for_sig(sig) regex = get_ref_regex_for_sig(sig)
if regex: if regex:
all_comment_ref_matches = re.finditer(r"(^|\W)(" + regex + r")(^|\W)", self.comment, re.IGNORECASE) all_comment_ref_matches = re.finditer(r"(^|\W)(" + regex + r")($|\W)", self.comment, re.IGNORECASE)
for ref_match in all_comment_ref_matches: for ref_match in all_comment_ref_matches:
self._append_sig_ref_if_missing(SIGRef(id=ref_match.group(2).upper(), sig=sig)) self._append_sig_ref_if_missing(SIGRef(id=ref_match.group(2).upper(), sig=sig))
+51
View File
@@ -0,0 +1,51 @@
from time import sleep
from pyhamtools.locator import latlong_to_locator
from data.sig_ref import SIGRef
from providers.sigrefdata.file_download_sig_ref_data_provider import FileDownloadSIGRefDataProvider
class COTA(FileDownloadSIGRefDataProvider):
"""SIG ref data provider for Castles on the Air"""
POLL_INTERVAL_DAYS = 30
SIG = "COTA"
DATA_URL = "https://www.cotagroup.org/cotagroup/map/data/castles-all-7d90ee2a5e1175e5dece1bbf9dc87504.json"
def __init__(self, provider_config):
super().__init__(self.SIG, provider_config, self.DATA_URL, self.POLL_INTERVAL_DAYS)
def _http_response_to_data(self, http_response):
new_data = []
data = http_response.json()
if isinstance(data, list):
for ref in data[2]:
ref_id = ref[3]
name = ref[4]
lat = float(ref[0])
lon = float(ref[1])
grid = latlong_to_locator(lat, lon)
new_data.append(
SIGRef(
sig=self.SIG,
id=ref_id,
name=name,
ref_type="Castle",
grid=grid,
latitude=lat,
longitude=lon,
)
)
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
# of the data in this case
if self._stop_event.is_set():
break
# Very short pause. This will extend the time to handle sig refs by a few seconds but will ensure some time
# is available for other threads e.g. the web server.
sleep(0.001)
return new_data
+1 -1
View File
@@ -76,7 +76,7 @@
</div> </div>
<script src="/static/js/add-spot.js?v=1788206062"></script> <script src="/static/js/add-spot.js?v=1788207475"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-add-spot").addClass("active"); $("#nav-link-add-spot").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -84,7 +84,7 @@
</div> </div>
<script src="/static/js/alerts.js?v=1788206062"></script> <script src="/static/js/alerts.js?v=1788207475"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-alerts").addClass("active"); $("#nav-link-alerts").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -76,8 +76,8 @@
</div> </div>
<script src="/static/js/spotsbandsandmap.js?v=1788206062"></script> <script src="/static/js/spotsbandsandmap.js?v=1788207475"></script>
<script src="/static/js/bands.js?v=1788206062"></script> <script src="/static/js/bands.js?v=1788207475"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-bands").addClass("active"); $("#nav-link-bands").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+5 -5
View File
@@ -1,6 +1,6 @@
{% extends "skeleton.html" %} {% extends "skeleton.html" %}
{% block head_extra %} {% block head_extra %}
<link rel="stylesheet" href="/static/css/style.css?v=1788206062" type="text/css"> <link rel="stylesheet" href="/static/css/style.css?v=1788207475" type="text/css">
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet"> <link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet"> <link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet"> <link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
@@ -15,10 +15,10 @@
window.fetchEventSource = fetchEventSource; window.fetchEventSource = fetchEventSource;
</script> </script>
<script src="/static/js/utils.js?v=1788206062"></script> <script src="/static/js/utils.js?v=1788207475"></script>
<script src="/static/js/ui-ham.js?v=1788206062"></script> <script src="/static/js/ui-ham.js?v=1788207475"></script>
<script src="/static/js/geo.js?v=1788206062"></script> <script src="/static/js/geo.js?v=1788207475"></script>
<script src="/static/js/common.js?v=1788206062"></script> <script src="/static/js/common.js?v=1788207475"></script>
{% end %} {% end %}
{% block body %} {% block body %}
<div class="container"> <div class="container">
+1 -1
View File
@@ -284,7 +284,7 @@
</div> </div>
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script> <script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
<script src="/static/js/conditions.js?v=1788206062"></script> <script src="/static/js/conditions.js?v=1788207475"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-conditions").addClass("active"); $("#nav-link-conditions").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -113,8 +113,8 @@
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
</script> </script>
<script src="/static/js/spotsbandsandmap.js?v=1788206061"></script> <script src="/static/js/spotsbandsandmap.js?v=1788207475"></script>
<script src="/static/js/map.js?v=1788206061"></script> <script src="/static/js/map.js?v=1788207475"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-map").addClass("active"); $("#nav-link-map").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -113,8 +113,8 @@
</div> </div>
<script src="/static/js/spotsbandsandmap.js?v=1788206061"></script> <script src="/static/js/spotsbandsandmap.js?v=1788207475"></script>
<script src="/static/js/spots.js?v=1788206061"></script> <script src="/static/js/spots.js?v=1788207475"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-spots").addClass("active"); $("#nav-link-spots").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -86,7 +86,7 @@
</div> </div>
</div> </div>
<script src="/static/js/status.js?v=1788206062"></script> <script src="/static/js/status.js?v=1788207475"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$("#nav-link-status").addClass("active"); $("#nav-link-status").addClass("active");