mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Add data providers for most other programmes
This commit is contained in:
29
data/spot.py
29
data/spot.py
@@ -1,11 +1,14 @@
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
from pyhamtools.locator import locator_to_latlong, latlong_to_locator
|
||||
|
||||
from core.constants import DXCC_FLAGS
|
||||
from core.utils import infer_mode_family_from_mode, infer_band_from_freq, infer_continent_from_callsign, \
|
||||
infer_country_from_callsign, infer_cq_zone_from_callsign, infer_itu_zone_from_callsign, infer_dxcc_id_from_callsign
|
||||
infer_country_from_callsign, infer_cq_zone_from_callsign, infer_itu_zone_from_callsign, infer_dxcc_id_from_callsign, \
|
||||
infer_mode_from_comment
|
||||
|
||||
|
||||
# Data class that defines a spot.
|
||||
@dataclass
|
||||
@@ -14,6 +17,8 @@ class Spot:
|
||||
dx_call: str = None
|
||||
# Callsign of the operator that has spotted them
|
||||
de_call: str = None
|
||||
# Name of the operator that has been spotted
|
||||
dx_name: str = None
|
||||
# Country of the DX operator
|
||||
dx_country: str = None
|
||||
# Country of the spotter
|
||||
@@ -48,6 +53,9 @@ class Spot:
|
||||
band_contrast_color: str = None
|
||||
# Time of the spot
|
||||
time: datetime = None
|
||||
# Time that this software received the spot. This is used with the "since" 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: datetime = datetime.now(pytz.UTC),
|
||||
# Comment left by the spotter, if any
|
||||
comment: str = None
|
||||
# Special Interest Group (SIG), e.g. outdoor activity programme such as POTA
|
||||
@@ -56,6 +64,8 @@ class Spot:
|
||||
sig_refs: list = None
|
||||
# SIG reference names
|
||||
sig_refs_names: list = None
|
||||
# Activation score. SOTA only
|
||||
activation_score: int = None
|
||||
# Maidenhead grid locator for the spot. This could be from a geographical reference e.g. POTA, or just from the country
|
||||
grid: str = None
|
||||
# Latitude & longitude, in degrees. This could be from a geographical reference e.g. POTA, or just from the country
|
||||
@@ -70,6 +80,7 @@ class Spot:
|
||||
|
||||
# Infer missing parameters where possible
|
||||
def infer_missing(self):
|
||||
# DX country, continent, zones etc. from callsign
|
||||
if self.dx_call and not self.dx_country:
|
||||
self.dx_country = infer_country_from_callsign(self.dx_call)
|
||||
if self.dx_call and not self.dx_continent:
|
||||
@@ -83,6 +94,7 @@ class Spot:
|
||||
if self.dx_dxcc_id and not self.dx_flag:
|
||||
self.dx_flag = DXCC_FLAGS[self.dx_dxcc_id]
|
||||
|
||||
# Spotter country, continent, zones etc. from callsign
|
||||
if self.de_call and not self.de_country:
|
||||
self.de_country = infer_country_from_callsign(self.de_call)
|
||||
if self.de_call and not self.de_continent:
|
||||
@@ -92,22 +104,31 @@ class Spot:
|
||||
if self.de_dxcc_id and not self.de_flag:
|
||||
self.de_flag = DXCC_FLAGS[self.de_dxcc_id]
|
||||
|
||||
# Band from frequency
|
||||
if self.freq and not self.band:
|
||||
band = infer_band_from_freq(self.freq)
|
||||
self.band = band.name
|
||||
self.band_color = band.color
|
||||
self.band_contrast_color = band.contrast_color
|
||||
|
||||
# Mode from comments, mode family from mode
|
||||
if self.comment and not self.mode:
|
||||
self.mode=infer_mode_from_comment(self.comment)
|
||||
if self.mode and not self.mode_family:
|
||||
self.mode_family=infer_mode_family_from_mode(self.mode)
|
||||
|
||||
# Grid to lat/lon and vice versa
|
||||
if self.grid and not self.latitude:
|
||||
ll = locator_to_latlong(self.grid)
|
||||
self.latitude = ll[0]
|
||||
self.longitude = ll[1]
|
||||
|
||||
if self.latitude and self.longitude and not self.grid:
|
||||
self.grid = latlong_to_locator(self.latitude, self.longitude, 8)
|
||||
|
||||
# TODO use QRZ provider to get grids, lat Lon, DX name
|
||||
# TODO lat/lon from DXCC centre?
|
||||
# QRT comment detection
|
||||
if self.comment and not self.qrt:
|
||||
self.qrt = "QRT" in self.comment.upper()
|
||||
|
||||
# TODO use QRZ/HamQTH provider to get grids, lat Lon, when missing; and DX name
|
||||
# credentials in config file which is .gitignored; sample provided
|
||||
# TODO lat/lon from DXCC centre as last resort?
|
||||
Reference in New Issue
Block a user