Support PARC references #156

This commit is contained in:
Ian Renton
2026-09-27 17:44:28 +01:00
parent 11743b9953
commit 7ec1302404
13 changed files with 107 additions and 16 deletions
+5
View File
@@ -300,6 +300,11 @@ activity_ref_data_providers:
- class: "Toilets" - class: "Toilets"
enabled: true enabled: true
- class: "PARC"
enabled: false
# PARC requires an API key to download the reference list. Contact Larry F5PYI for a key.
api_key: ""
# Callsign data providers to use. These allow Spothole to provide information about callsigns, either from static # Callsign data providers to use. These allow Spothole to provide information about callsigns, either from static
# lookups or from web-based services such as QRZ. Note that use of QRZ and HamQTH is *on behalf of the user*, and # lookups or from web-based services such as QRZ. Note that use of QRZ and HamQTH is *on behalf of the user*, and
+1
View File
@@ -141,6 +141,7 @@ class ActivityName(str, Enum):
JOTA = "JOTA" JOTA = "JOTA"
RAILWAYS = "Railways" RAILWAYS = "Railways"
TOILETS = "Toilets" TOILETS = "Toilets"
PARC = "PARC"
def __str__(self): def __str__(self):
return str(self.value) return str(self.value)
+11
View File
@@ -248,6 +248,17 @@ ACTIVITIES: dict[ActivityName, Activity] = {
comment_names=[], comment_names=[],
icon="fa-square", icon="fa-square",
), ),
ActivityName.PARC: Activity(
name=ActivityName.PARC,
description="Protected Area Radio Community",
activity_type=ActivityType.ADVENTURE,
has_refs=True,
refs_globally_unique=True,
ref_type=ActivityRefType.PARK,
ref_regex=r"[A-Za-z]{2}-[A-Za-z]{2,3}-[0-9]{4}",
comment_names=["PARC"],
icon="fa-pagelines",
),
ActivityName.ZLOTA: Activity( ActivityName.ZLOTA: Activity(
name=ActivityName.ZLOTA, name=ActivityName.ZLOTA,
description="New Zealand on the Air", description="New Zealand on the Air",
+1 -1
View File
@@ -382,7 +382,7 @@ class Spot:
if mode_tag and not self.propagation_mode: if mode_tag and not self.propagation_mode:
if mode_tag in PROPAGATION_MODES: if mode_tag in PROPAGATION_MODES:
self.propagation_mode = PROPAGATION_MODES[mode_tag] self.propagation_mode = PROPAGATION_MODES[mode_tag]
else: elif mode_tag != "?":
self.propagation_mode = mode_tag self.propagation_mode = mode_tag
logger.info(f"Seen a new propagation mode tag not yet in the system: {mode_tag}") logger.info(f"Seen a new propagation mode tag not yet in the system: {mode_tag}")
+74
View File
@@ -0,0 +1,74 @@
import json
import logging
from time import sleep
from pyhamtools.locator import locator_to_latlong
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from providers.activityrefdata.file_download_activity_ref_data_provider import (
FileDownloadActivityRefDataProvider,
)
logger = logging.getLogger(__name__)
class PARC(FileDownloadActivityRefDataProvider):
"""Activity ref data provider for Protected Area Radiu Community"""
POLL_INTERVAL_DAYS = 30
ACTIVITY = ActivityName.PARC
DATA_URL = "https://parc-community.com/api/partner/parks?format=json"
def __init__(self, provider_config):
# Ensure there is an API key in our config, and set up the query URL using it. If no key is provided,
# disable this spot provider.
api_key = provider_config.get("api_key", "")
if api_key == "":
provider_config["enabled"] = False
logger.warning(
"PARC activity reference provider configured but no api key was provided, this API will not be queried."
)
super().__init__(self.ACTIVITY, provider_config, self.DATA_URL + "&key=" + api_key, self.POLL_INTERVAL_DAYS)
def _http_response_to_data(self, http_response):
new_data = []
# Use stdlib json rather than http_response.json(), as the PARC data can contain NaN values which simplejson
# rejects
data = json.loads(http_response.text)
for ref in data["parks"]:
ref_id = ref["reference"]
name = ref["name"]
grid = ref["grid"]
lat = ref["latitude"]
lon = ref["longitude"]
# grid, lat & lon can all be null, but sometimes we have grid but not lat/lon
if grid and (lat is None or lon is None):
lat, lon = locator_to_latlong(grid)
new_data.append(
ActivityRef(
activity=self.ACTIVITY,
id=ref_id,
# Name is sometimes NaN, not even a string somehow?
name=name if isinstance(name, str) else None,
ref_type=ActivityRefType.PARK,
url=f"https://parc-community.com/parks/{ref_id}",
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 activity 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
@@ -130,7 +130,7 @@
const ALLOW_UPSTREAM_SPOTTING = {% raw safe_json_dumps(web_ui_options["allow_upstream_spotting"]) %}; const ALLOW_UPSTREAM_SPOTTING = {% raw safe_json_dumps(web_ui_options["allow_upstream_spotting"]) %};
</script> </script>
<script src="/static/js/add-spot.js?v=1790524344"></script> <script src="/static/js/add-spot.js?v=1790527469"></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
@@ -87,7 +87,7 @@
</div> </div>
<script src="/static/js/alerts.js?v=1790524344"></script> <script src="/static/js/alerts.js?v=1790527469"></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
@@ -82,8 +82,8 @@
const BANDS = {% raw safe_json_dumps(options["bands"]) %}; const BANDS = {% raw safe_json_dumps(options["bands"]) %};
</script> </script>
<script src="/static/js/spotsbandsandmap.js?v=1790524344"></script> <script src="/static/js/spotsbandsandmap.js?v=1790527469"></script>
<script src="/static/js/bands.js?v=1790524344"></script> <script src="/static/js/bands.js?v=1790527469"></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=1790524344" type="text/css"> <link rel="stylesheet" href="/static/css/style.css?v=1790527469" 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">
@@ -16,10 +16,10 @@
window.fetchEventSource = fetchEventSource; window.fetchEventSource = fetchEventSource;
</script> </script>
<script src="/static/js/utils.js?v=1790524344"></script> <script src="/static/js/utils.js?v=1790527469"></script>
<script src="/static/js/ui-ham.js?v=1790524344"></script> <script src="/static/js/ui-ham.js?v=1790527469"></script>
<script src="/static/js/geo.js?v=1790524344"></script> <script src="/static/js/geo.js?v=1790527469"></script>
<script src="/static/js/common.js?v=1790524344"></script> <script src="/static/js/common.js?v=1790527469"></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=1790524344"></script> <script src="/static/js/conditions.js?v=1790527469"></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
@@ -115,8 +115,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=1790524344"></script> <script src="/static/js/spotsbandsandmap.js?v=1790527468"></script>
<script src="/static/js/map.js?v=1790524344"></script> <script src="/static/js/map.js?v=1790527468"></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
@@ -127,8 +127,8 @@
</div> </div>
<script src="/static/js/spotsbandsandmap.js?v=1790524344"></script> <script src="/static/js/spotsbandsandmap.js?v=1790527468"></script>
<script src="/static/js/spots.js?v=1790524344"></script> <script src="/static/js/spots.js?v=1790527468"></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
@@ -96,7 +96,7 @@
</div> </div>
</div> </div>
<script src="/static/js/status.js?v=1790524344"></script> <script src="/static/js/status.js?v=1790527469"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$("#nav-link-status").addClass("active"); $("#nav-link-status").addClass("active");