mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 06:17:41 +00:00
Support COTA. Closes #131
This commit is contained in:
@@ -258,6 +258,9 @@ sig_ref_data_providers:
|
||||
- class: "DTMBA"
|
||||
enabled: true
|
||||
|
||||
- class: "COTA"
|
||||
enabled: true
|
||||
|
||||
- class: "Toilets"
|
||||
enabled: true
|
||||
|
||||
|
||||
@@ -233,6 +233,15 @@ SIGS = [
|
||||
icon="fa-ship",
|
||||
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(
|
||||
name="Toilets",
|
||||
comment_names=[],
|
||||
|
||||
+2
-2
@@ -31,10 +31,10 @@ def infer_mode_from_comment(comment):
|
||||
"""Infer a mode from the comment"""
|
||||
|
||||
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
|
||||
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 None
|
||||
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ class Spot:
|
||||
sig = self.sig_refs[0].sig.upper()
|
||||
regex = get_ref_regex_for_sig(sig)
|
||||
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:
|
||||
self._append_sig_ref_if_missing(SIGRef(id=ref_match.group(2).upper(), sig=sig))
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
</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 () {
|
||||
$("#nav-link-add-spot").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/alerts.js?v=1788206062"></script>
|
||||
<script src="/static/js/alerts.js?v=1788207475"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-alerts").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1788206062"></script>
|
||||
<script src="/static/js/bands.js?v=1788206062"></script>
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1788207475"></script>
|
||||
<script src="/static/js/bands.js?v=1788207475"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-bands").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% 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/fontawesome-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;
|
||||
</script>
|
||||
|
||||
<script src="/static/js/utils.js?v=1788206062"></script>
|
||||
<script src="/static/js/ui-ham.js?v=1788206062"></script>
|
||||
<script src="/static/js/geo.js?v=1788206062"></script>
|
||||
<script src="/static/js/common.js?v=1788206062"></script>
|
||||
<script src="/static/js/utils.js?v=1788207475"></script>
|
||||
<script src="/static/js/ui-ham.js?v=1788207475"></script>
|
||||
<script src="/static/js/geo.js?v=1788207475"></script>
|
||||
<script src="/static/js/common.js?v=1788207475"></script>
|
||||
{% end %}
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
</div>
|
||||
|
||||
<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 () {
|
||||
$("#nav-link-conditions").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
+2
-2
@@ -113,8 +113,8 @@
|
||||
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
||||
</script>
|
||||
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1788206061"></script>
|
||||
<script src="/static/js/map.js?v=1788206061"></script>
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1788207475"></script>
|
||||
<script src="/static/js/map.js?v=1788207475"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-map").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -113,8 +113,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1788206061"></script>
|
||||
<script src="/static/js/spots.js?v=1788206061"></script>
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1788207475"></script>
|
||||
<script src="/static/js/spots.js?v=1788207475"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-spots").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/status.js?v=1788206062"></script>
|
||||
<script src="/static/js/status.js?v=1788207475"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#nav-link-status").addClass("active");
|
||||
|
||||
Reference in New Issue
Block a user