Icon lookup for SIGs in preparation for #47. Improved ZLOTA spotter lookup.

This commit is contained in:
Ian Renton
2025-10-20 10:33:18 +01:00
parent ae72649df8
commit a21782cb62
18 changed files with 89 additions and 60 deletions

View File

@@ -9,6 +9,7 @@ import pytz
from core.constants import DXCC_FLAGS
from core.lookup_helper import lookup_helper
from core.utility_functions import get_icon_for_sig
# Data class that defines an alert.
@@ -59,7 +60,7 @@ class Alert:
# Activation score. SOTA only
activation_score: int = None
# Icon, from the Font Awesome set. This is fairly opinionated but is here to help the alerthole web UI and Field alertter. Does not include the "fa-" prefix.
icon: str = "question"
icon: str = None
# Whether this alert is for a DXpedition, as opposed to e.g. an xOTA programme.
is_dxpedition: bool = False
# Where we got the alert from, e.g. "POTA", "SOTA"...
@@ -100,6 +101,10 @@ class Alert:
if self.dx_dxcc_id and self.dx_dxcc_id in DXCC_FLAGS and not self.dx_flag:
self.dx_flag = DXCC_FLAGS[self.dx_dxcc_id]
# Icon from SIG
if self.sig and not self.icon:
self.icon = get_icon_for_sig(self.sig)
# DX operator details lookup, using QRZ.com. This should be the last resort compared to taking the data from
# the actual alertting service, e.g. we don't want to accidentally use a user's QRZ.com home lat/lon instead of
# the one from the park reference they're at.

12
data/sig.py Normal file
View File

@@ -0,0 +1,12 @@
from dataclasses import dataclass
# Data class that defines a Special Interest Group.
@dataclass
class SIG:
# SIG name, e.g. "POTA"
name: str
# Description, e.g. "Parks on the Air"
description: str
# Icon to use for it, from the Font Awesome set. This is fairly opinionated but is here to help the Spothole web UI
# and Field Spotter. Does not include the "fa-" prefix.
icon: str

View File

@@ -11,6 +11,7 @@ from pyhamtools.locator import locator_to_latlong, latlong_to_locator
from core.constants import DXCC_FLAGS
from core.lookup_helper import lookup_helper
from core.utility_functions import get_icon_for_sig
# Data class that defines a spot.
@@ -113,7 +114,7 @@ class Spot:
# Icon, from the Font Awesome set. This is fairly opinionated but is here to help the Spothole web UI and Field
# Spotter. Does not include the "fa-" prefix.
icon: str = "question"
icon: str = None
# Colour to represent this spot, if a client chooses to colour spots based on their frequency band, using PSK
# Reporter's default colours. HTML colour e.g. hex. A contrast colour is also provided which will be black or white.
band_color: str = None
@@ -218,6 +219,10 @@ class Spot:
if self.mode and not self.mode_type:
self.mode_type = lookup_helper.infer_mode_type_from_mode(self.mode)
# Icon from SIG
if self.sig and not self.icon:
self.icon = get_icon_for_sig(self.sig)
# DX Grid to lat/lon and vice versa
if self.dx_grid and not self.dx_latitude:
ll = locator_to_latlong(self.dx_grid)
@@ -237,7 +242,8 @@ class Spot:
# Clean up comments
if self.comment:
comment = re.sub(r"\[.*]:", "", self.comment)
comment = re.sub(r"\(de [A-Za-z0-9]*\)", "", self.comment)
comment = re.sub(r"\[.*]:", "", comment)
comment = re.sub(r"\[.*]", "", comment)
comment = re.sub(r"\"\"", "", comment)
self.comment = comment.strip()
@@ -269,8 +275,8 @@ class Spot:
self.dx_location_good = self.dx_location_source == "SPOT" or (
self.dx_location_source == "QRZ" and not "/" in self.dx_call)
# DE of "RBNHOLE" and "SOTAMAT" are not things we can look up location for
if self.de_call != "RBNHOLE" and self.de_call != "SOTAMAT":
# DE of "RBNHOLE", "SOTAMAT" and "ZLOTA" are not things we can look up location for
if self.de_call != "RBNHOLE" and self.de_call != "SOTAMAT" and self.de_call != "ZLOTA":
# DE operator position lookup, using QRZ.com.
if self.de_call and not self.de_latitude:
latlon = lookup_helper.infer_latlon_from_callsign_qrz(self.de_call)