mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-24 05:35:10 +00:00
Merge branch 'main' into 95-send-spots-to-xota
# Conflicts: # README.md # server/handlers/api/addspot.py # server/handlers/api/options.py # spotproviders/tiles.py # templates/about.html # templates/add_spot.html # templates/alerts.html # templates/api_only_home.html # templates/bands.html # templates/base.html # templates/conditions.html # templates/map.html # templates/spots.html # templates/status.html # webassets/css/style.css # webassets/js/add-spot.js # webassets/js/geo.js # webassets/js/ui-ham.js # webassets/js/utils.js
This commit is contained in:
@@ -15,51 +15,51 @@ class Alert:
|
||||
"""Data class that defines an alert."""
|
||||
|
||||
# Unique identifier for the alert
|
||||
id: str = None
|
||||
id: str | None = None
|
||||
# Callsigns of the operators that has been alerted
|
||||
dx_calls: list = None
|
||||
dx_calls: list | None = None
|
||||
# Names of the operators that has been alerted
|
||||
dx_names: list = None
|
||||
dx_names: list | None = None
|
||||
# Country of the DX operator
|
||||
dx_country: str = None
|
||||
dx_country: str | None = None
|
||||
# Country flag of the DX operator
|
||||
dx_flag: str = None
|
||||
dx_flag: str | None = None
|
||||
# Continent of the DX operator
|
||||
dx_continent: str = None
|
||||
dx_continent: str | None = None
|
||||
# DXCC ID of the DX operator
|
||||
dx_dxcc_id: int = None
|
||||
dx_dxcc_id: int | None = None
|
||||
# CQ zone of the DX operator
|
||||
dx_cq_zone: int = None
|
||||
dx_cq_zone: int | None = None
|
||||
# ITU zone of the DX operator
|
||||
dx_itu_zone: int = None
|
||||
dx_itu_zone: int | None = None
|
||||
# Intended frequencies & modes of operation. Essentially just a different kind of comment field.
|
||||
freqs_modes: str = None
|
||||
freqs_modes: str | None = None
|
||||
# Start time of the activation, UTC seconds since UNIX epoch
|
||||
start_time: float = None
|
||||
start_time: float | None = None
|
||||
# Start time of the activation of the alert, ISO 8601
|
||||
start_time_iso: str = None
|
||||
start_time_iso: str | None = None
|
||||
# End time of the activation, UTC seconds since UNIX epoch. Optional
|
||||
end_time: float = None
|
||||
end_time: float | None = None
|
||||
# End time of the activation of the alert, ISO 8601
|
||||
end_time_iso: str = None
|
||||
end_time_iso: str | None = None
|
||||
# Time that this software received the alert, UTC seconds since UNIX epoch. This is used with the "since_received"
|
||||
# call to our API to receive all data that is new to us, even if by a quirk of the API it might be older than the
|
||||
# list time the client polled the API.
|
||||
received_time: float = None
|
||||
received_time: float | None = None
|
||||
# Time that this software received the alert, ISO 8601
|
||||
received_time_iso: str = None
|
||||
received_time_iso: str | None = None
|
||||
# Comment made by the alerter, if any
|
||||
comment: str = None
|
||||
comment: str | None = None
|
||||
# Special Interest Group (SIG), e.g. outdoor activity programme such as POTA
|
||||
sig: str = None
|
||||
sig: str | None = None
|
||||
# SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
||||
sig_refs: list = None
|
||||
sig_refs: list | None = 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"...
|
||||
source: str = None
|
||||
source: str | None = None
|
||||
# The ID the source gave it, if any.
|
||||
source_id: str = None
|
||||
source_id: str | None = None
|
||||
|
||||
def infer_missing(self, credentials=None):
|
||||
"""Infer missing parameters where possible"""
|
||||
|
||||
@@ -6,10 +6,10 @@ class LookupCredentials:
|
||||
"""Per-request credentials for QRZ.com and HamQTH online callsign lookups."""
|
||||
qrz_username: str = ""
|
||||
qrz_password: str = ""
|
||||
qrz_session_key: str = "" # alternative to username/password
|
||||
qrz_session_key: str = "" # alternative to username/password
|
||||
hamqth_username: str = ""
|
||||
hamqth_password: str = ""
|
||||
hamqth_session_id: str = "" # alternative to username/password
|
||||
hamqth_session_id: str = "" # alternative to username/password
|
||||
|
||||
|
||||
def extract_credentials(query_params):
|
||||
|
||||
@@ -11,14 +11,14 @@ class SIGRef:
|
||||
# SIG that this reference is in, e.g. "POTA".
|
||||
sig: str
|
||||
# Name of the reference, e.g. "Null Country Park", if known.
|
||||
name: str = None
|
||||
name: str | None = None
|
||||
# URL to look up more information about the reference, if known.
|
||||
url: str = None
|
||||
url: str | None = None
|
||||
# Latitude of the reference, if known.
|
||||
latitude: float = None
|
||||
latitude: float | None = None
|
||||
# Longitude of the reference, if known.
|
||||
longitude: float = None
|
||||
longitude: float | None = None
|
||||
# Maidenhead grid reference of the reference, if known.
|
||||
grid: str = None
|
||||
grid: str | None = None
|
||||
# Activation score. SOTA only
|
||||
activation_score: int = None
|
||||
activation_score: int | None = None
|
||||
|
||||
@@ -110,11 +110,11 @@ class HFBandCondition:
|
||||
"""Data class representing HF propagation conditions for certain bands and time of day."""
|
||||
|
||||
# Band name, e.g. "80m-40m", "20m-17m", "10m-6m"
|
||||
band: str = None
|
||||
band: str | None = None
|
||||
# Time of day: "day" or "night"
|
||||
time: str = None
|
||||
time: str | None = None
|
||||
# Propagation condition: "Good", "Fair", or "Poor"
|
||||
condition: str = None
|
||||
condition: str | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -122,66 +122,66 @@ class SolarConditions:
|
||||
"""Data class representing current solar and propagation conditions."""
|
||||
|
||||
# Time the data was last updated at the source, UTC seconds since UNIX epoch
|
||||
updated: float = None
|
||||
updated: float | None = None
|
||||
# Solar Flux Index (SFI)
|
||||
sfi: int = None
|
||||
sfi: int | None = None
|
||||
# A-index (daily geomagnetic activity)
|
||||
a_index: int = None
|
||||
a_index: int | None = None
|
||||
# K-index (3-hour geomagnetic activity)
|
||||
k_index: int = None
|
||||
k_index: int | None = None
|
||||
# X-ray flux class, e.g. "B2.3", "C1.0"
|
||||
xray: str = None
|
||||
xray: str | None = None
|
||||
# Proton flux
|
||||
proton_flux: int = None
|
||||
proton_flux: int | None = None
|
||||
# Electron flux
|
||||
electron_flux: int = None
|
||||
electron_flux: int | None = None
|
||||
# Aurora activity level
|
||||
aurora: int = None
|
||||
aurora: int | None = None
|
||||
# Latitude in degrees of the aurora boundary
|
||||
aurora_latitude: float = None
|
||||
aurora_latitude: float | None = None
|
||||
# Sunspot count
|
||||
sunspots: int = None
|
||||
sunspots: int | None = None
|
||||
# Solar wind speed in km/s
|
||||
solar_wind: float = None
|
||||
solar_wind: float | None = None
|
||||
# Interplanetary magnetic field strength in nT
|
||||
magnetic_field: float = None
|
||||
magnetic_field: float | None = None
|
||||
# Geomagnetic field condition, e.g. "Quiet", "Unsettled", "Active", "Storm"
|
||||
geomag_field: str = None
|
||||
geomag_field: str | None = None
|
||||
# Geomagnetic background noise level, e.g. "S0", "S1", "S2"
|
||||
geomag_noise: str = None
|
||||
geomag_noise: str | None = None
|
||||
# HF band propagation conditions, keyed by "{band}-{time}" e.g. "80m-40m-day"
|
||||
hf_conditions: dict = None
|
||||
hf_conditions: dict | None = None
|
||||
# VHF propagation conditions, keyed by condition name
|
||||
vhf_conditions: dict = None
|
||||
vhf_conditions: dict | None = None
|
||||
# NOAA Kp index 3-day forecast, keyed by UNIX timestamp of the start of each 3-hour UTC period
|
||||
k_index_forecast: dict = None
|
||||
k_index_forecast: dict | None = None
|
||||
# NOAA Solar Radiation Storm (S1 or greater) probability forecast, keyed by UNIX timestamp of start of day UTC
|
||||
solar_storm_forecast: dict = None
|
||||
solar_storm_forecast: dict | None = None
|
||||
# NOAA Radio Blackout (R1-R2) probability forecast, keyed by UNIX timestamp of start of day UTC
|
||||
blackout_forecast_r1r2: dict = None
|
||||
blackout_forecast_r1r2: dict | None = None
|
||||
# NOAA Radio Blackout (R3 or greater) probability forecast, keyed by UNIX timestamp of start of day UTC
|
||||
blackout_forecast_r3_or_greater: dict = None
|
||||
blackout_forecast_r3_or_greater: dict | None = None
|
||||
# Ionosonde measurements, dict keyed by URSI code, values are dicts with keys: ursi, name, fof2, muf, luf,
|
||||
# band_states. Populated by GIROIonosonde or KC2GProp providers.
|
||||
ionosonde_data: dict = None
|
||||
ionosonde_data: dict | None = None
|
||||
|
||||
# Derived values (populated by infer_descriptions())
|
||||
# HF radio blackout risk description, derived from xray
|
||||
xray_desc: str = None
|
||||
xray_desc: str | None = None
|
||||
# HF radio blackout scale number (R0-R5), derived from xray
|
||||
radio_blackout_scale: int = None
|
||||
radio_blackout_scale: int | None = None
|
||||
# Solar radiation storm level description, derived from proton_flux
|
||||
proton_flux_desc: str = None
|
||||
proton_flux_desc: str | None = None
|
||||
# Solar radiation storm scale number (S0-S5), derived from proton_flux
|
||||
solar_storm_scale: int = None
|
||||
solar_storm_scale: int | None = None
|
||||
# Geomagnetic storm level description, derived from k_index
|
||||
geomag_storm_desc: str = None
|
||||
geomag_storm_desc: str | None = None
|
||||
# Geomagnetic storm scale number (G0-G5), derived from k_index
|
||||
geomag_storm_scale: int = None
|
||||
geomag_storm_scale: int | None = None
|
||||
# Overall HF band conditions summary, derived from sfi
|
||||
band_conditions_desc: str = None
|
||||
band_conditions_desc: str | None = None
|
||||
# Electron flux description, derived from electron_flux
|
||||
electron_flux_desc: str = None
|
||||
electron_flux_desc: str | None = None
|
||||
|
||||
def infer_descriptions(self):
|
||||
"""Populate derived text description fields from the current numeric/raw field values."""
|
||||
|
||||
96
data/spot.py
96
data/spot.py
@@ -23,38 +23,38 @@ class Spot:
|
||||
"""Data class that defines a spot."""
|
||||
|
||||
# Unique identifier for the spot
|
||||
id: str = None
|
||||
id: str | None = None
|
||||
|
||||
# DX (spotted) operator info
|
||||
|
||||
# Callsign of the operator that has been spotted
|
||||
dx_call: str = None
|
||||
dx_call: str | None = None
|
||||
# Name of the operator that has been spotted
|
||||
dx_name: str = None
|
||||
dx_name: str | None = None
|
||||
# QTH of the operator that has been spotted. This could be from any SIG refs or could be from online lookup of their
|
||||
# home QTH.
|
||||
dx_qth: str = None
|
||||
dx_qth: str | None = None
|
||||
# Country of the DX operator
|
||||
dx_country: str = None
|
||||
dx_country: str | None = None
|
||||
# Country flag of the DX operator
|
||||
dx_flag: str = None
|
||||
dx_flag: str | None = None
|
||||
# Continent of the DX operator
|
||||
dx_continent: str = None
|
||||
dx_continent: str | None = None
|
||||
# DXCC ID of the DX operator
|
||||
dx_dxcc_id: int = None
|
||||
dx_dxcc_id: int | None = None
|
||||
# CQ zone of the DX operator
|
||||
dx_cq_zone: int = None
|
||||
dx_cq_zone: int | None = None
|
||||
# ITU zone of the DX operator
|
||||
dx_itu_zone: int = None
|
||||
dx_itu_zone: int | None = None
|
||||
# If this is an APRS/Packet/etc spot, what SSID was the DX operator using?
|
||||
dx_ssid: str = None
|
||||
dx_ssid: str | None = None
|
||||
# Maidenhead grid locator for the DX. This could be from a geographical reference e.g. POTA, or just from the
|
||||
# country
|
||||
dx_grid: str = None
|
||||
dx_grid: str | None = None
|
||||
# Latitude & longitude of the DX, in degrees. This could be from a geographical reference e.g. POTA, or from a QRZ
|
||||
# lookup
|
||||
dx_latitude: float = None
|
||||
dx_longitude: float = None
|
||||
dx_latitude: float | None = None
|
||||
dx_longitude: float | None = None
|
||||
# DX Location source. Indicates how accurate the location might be. Values: "SPOT", "WAB/WAI GRID", "HOME QTH",
|
||||
# "DXCC", "NONE"
|
||||
dx_location_source: str = "NONE"
|
||||
@@ -66,70 +66,70 @@ class Spot:
|
||||
# DE (Spotter) info
|
||||
|
||||
# Callsign of the spotter
|
||||
de_call: str = None
|
||||
de_call: str | None = None
|
||||
# Country of the spotter
|
||||
de_country: str = None
|
||||
de_country: str | None = None
|
||||
# Country flag of the spotter
|
||||
de_flag: str = None
|
||||
de_flag: str | None = None
|
||||
# Continent of the spotter
|
||||
de_continent: str = None
|
||||
de_continent: str | None = None
|
||||
# DXCC ID of the spotter
|
||||
de_dxcc_id: int = None
|
||||
de_dxcc_id: int | None = None
|
||||
# If this is an APRS/Packet/etc spot, what SSID was the spotter/receiver using?
|
||||
de_ssid: str = None
|
||||
de_ssid: str | None = None
|
||||
# Maidenhead grid locator for the spotter. This is not going to be from a xOTA reference so it will likely just be
|
||||
# a QRZ or DXCC lookup. If the spotter is also portable, this is probably wrong, but it's good enough for some
|
||||
# simple mapping.
|
||||
de_grid: str = None
|
||||
de_grid: str | None = None
|
||||
# Latitude & longitude of the DX, in degrees. This is not going to be from a xOTA reference so it will likely just
|
||||
# be a QRZ or DXCC lookup. If the spotter is also portable, this is probably wrong, but it's good enough for some
|
||||
# simple mapping.
|
||||
de_latitude: float = None
|
||||
de_longitude: float = None
|
||||
de_latitude: float | None = None
|
||||
de_longitude: float | None = None
|
||||
|
||||
# General QSO info
|
||||
|
||||
# Reported mode, such as SSB, PHONE, CW, FT8...
|
||||
mode: str = None
|
||||
mode: str | None = None
|
||||
# Inferred mode "family". One of "CW", "PHONE" or "DIGI".
|
||||
mode_type: str = None
|
||||
mode_type: str | None = None
|
||||
# Source of the mode information. "SPOT", "COMMENT", "BANDPLAN" or "NONE"
|
||||
mode_source: str = "NONE"
|
||||
# Frequency, in Hz
|
||||
freq: float = None
|
||||
freq: float | None = None
|
||||
# Band, defined by the frequency, e.g. "40m" or "70cm"
|
||||
band: str = None
|
||||
band: str | None = None
|
||||
# Comment left by the spotter, if any
|
||||
comment: str = None
|
||||
comment: str | None = None
|
||||
# QRT state. Some APIs return spots marked as QRT. Otherwise we can check the comments.
|
||||
qrt: bool = False
|
||||
|
||||
# Special Interest Group info
|
||||
|
||||
# Special Interest Group (SIG), e.g. outdoor activity programme such as POTA
|
||||
sig: str = None
|
||||
sig: str | None = None
|
||||
# SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
||||
sig_refs: list = None
|
||||
sig_refs: list | None = None
|
||||
|
||||
# Timing info
|
||||
|
||||
# Time of the spot, UTC seconds since UNIX epoch
|
||||
time: float = None
|
||||
time: float | None = None
|
||||
# Time of the spot, ISO 8601
|
||||
time_iso: str = None
|
||||
time_iso: str | None = None
|
||||
# Time that this software received the spot, UTC seconds since UNIX epoch. This is used with the "since_received"
|
||||
# call to our API to receive all data that is new to us, even if by a quirk of the API it might be older than the
|
||||
# list time the client polled the API.
|
||||
received_time: float = None
|
||||
received_time: float | None = None
|
||||
# Time that this software received the spot, ISO 8601
|
||||
received_time_iso: str = None
|
||||
received_time_iso: str | None = None
|
||||
|
||||
# Source info
|
||||
|
||||
# Where we got the spot from, e.g. "POTA", "Cluster"...
|
||||
source: str = None
|
||||
source: str | None = None
|
||||
# The ID the source gave it, if any.
|
||||
source_id: str = None
|
||||
source_id: str | None = None
|
||||
|
||||
def infer_missing(self, credentials=None):
|
||||
"""Infer missing parameters where possible"""
|
||||
@@ -342,9 +342,10 @@ class Spot:
|
||||
# Determine a "QTH" string. If we have a SIG ref, pick the first one and turn it into a suitable string,
|
||||
# otherwise see what they have set on an online lookup service.
|
||||
if self.sig_refs and len(self.sig_refs) > 0:
|
||||
self.dx_qth = self.sig_refs[0].id
|
||||
qth = self.sig_refs[0].id
|
||||
if self.sig_refs[0].name:
|
||||
self.dx_qth = self.dx_qth + " " + self.sig_refs[0].name
|
||||
qth += " " + self.sig_refs[0].name
|
||||
self.dx_qth = qth
|
||||
else:
|
||||
self.dx_qth = lookup_helper.infer_qth_from_callsign_online_lookup(self.dx_call, credentials)
|
||||
|
||||
@@ -360,10 +361,11 @@ class Spot:
|
||||
# It looks like we can sometimes get a string into lat/lon, so try to parse as float, reject if not valid
|
||||
if isinstance(self.dx_latitude, str) or isinstance(self.dx_longitude, str):
|
||||
try:
|
||||
self.dx_latitude = float(self.dx_latitude)
|
||||
self.dx_longitude = float(self.dx_longitude)
|
||||
self.dx_latitude = float(str(self.dx_latitude))
|
||||
self.dx_longitude = float(str(self.dx_longitude))
|
||||
except (TypeError, ValueError):
|
||||
logging.warning("Received non-numeric strings in lat/lon (" + str(self.dx_latitude) + ", " + str(self.dx_longitude) + ") for call " + self.dx_call + ", rejecting it")
|
||||
logging.warning("Received non-numeric strings in lat/lon (" + str(self.dx_latitude) + ", " + str(
|
||||
self.dx_longitude) + ") for call " + str(self.dx_call) + ", rejecting it")
|
||||
self.dx_latitude = None
|
||||
self.dx_longitude = None
|
||||
|
||||
@@ -381,10 +383,10 @@ class Spot:
|
||||
|
||||
# DX Location is "good" if it is from a spot, or from QRZ if the callsign doesn't contain a slash, so the operator
|
||||
# is likely at home.
|
||||
self.dx_location_good = self.dx_latitude and self.dx_longitude and (
|
||||
self.dx_location_good = bool(self.dx_latitude and self.dx_longitude and (
|
||||
self.dx_location_source == "SPOT" or self.dx_location_source == "SIG REF LOOKUP"
|
||||
or self.dx_location_source == "WAB/WAI GRID"
|
||||
or (self.dx_location_source == "HOME QTH" and not "/" in self.dx_call))
|
||||
or (self.dx_location_source == "HOME QTH" and "/" not in (self.dx_call or ""))))
|
||||
|
||||
# DE with no digits and APRS servers starting "T2" are not things we can look up location for
|
||||
if self.de_call and any(char.isdigit() for char in self.de_call) and not (
|
||||
@@ -413,16 +415,16 @@ class Spot:
|
||||
def _append_sig_ref_if_missing(self, new_sig_ref):
|
||||
"""Append a sig_ref to the list, so long as it's not already there."""
|
||||
|
||||
if not self.sig_refs:
|
||||
self.sig_refs = []
|
||||
sig_refs = self.sig_refs or []
|
||||
self.sig_refs = sig_refs
|
||||
new_sig_ref.id = new_sig_ref.id.strip().upper()
|
||||
new_sig_ref.sig = new_sig_ref.sig.strip().upper()
|
||||
if new_sig_ref.id == "":
|
||||
return
|
||||
for sig_ref in self.sig_refs:
|
||||
for sig_ref in sig_refs:
|
||||
if sig_ref.id == new_sig_ref.id and sig_ref.sig == new_sig_ref.sig:
|
||||
return
|
||||
self.sig_refs.append(new_sig_ref)
|
||||
sig_refs.append(new_sig_ref)
|
||||
|
||||
def expired(self):
|
||||
"""Decide if this spot has expired (in which case it should not be added to the system in the first place, and not
|
||||
|
||||
Reference in New Issue
Block a user