mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Infer location from WAB/WAI grid. Closes #62
This commit is contained in:
31
data/spot.py
31
data/spot.py
@@ -10,8 +10,9 @@ import pytz
|
||||
from pyhamtools.locator import locator_to_latlong, latlong_to_locator
|
||||
|
||||
from core.constants import DXCC_FLAGS
|
||||
from core.geo_utils import wab_wai_square_to_lat_lon
|
||||
from core.lookup_helper import lookup_helper
|
||||
from core.utils import get_icon_for_sig
|
||||
from core.sig_utils import get_icon_for_sig
|
||||
|
||||
|
||||
# Data class that defines a spot.
|
||||
@@ -20,7 +21,6 @@ class Spot:
|
||||
# Unique identifier for the spot
|
||||
id: str = None
|
||||
|
||||
|
||||
# DX (spotted) operator info
|
||||
|
||||
# Callsign of the operator that has been spotted
|
||||
@@ -51,12 +51,13 @@ class Spot:
|
||||
# lookup
|
||||
dx_latitude: float = None
|
||||
dx_longitude: float = None
|
||||
# DX Location source. Indicates how accurate the location might be. Values: "SPOT", "QRZ, "DXCC", "NONE"
|
||||
# DX Location source. Indicates how accurate the location might be. Values: "SPOT", "WAB/WAI GRID", "QRZ", "DXCC", "NONE"
|
||||
dx_location_source: str = "NONE"
|
||||
# DX Location good. Indicates that the software thinks the location data is good enough to plot on a map.
|
||||
# DX Location good. Indicates that the software thinks the location data is good enough to plot on a map. This is
|
||||
# true if the location source is "SPOT" or "WAB/WAI GRID", or if the location source is "QRZ" and the DX callsign
|
||||
# doesn't have a suffix like /P.
|
||||
dx_location_good: bool = False
|
||||
|
||||
|
||||
# DE (Spotter) info
|
||||
|
||||
# Callsign of the spotter
|
||||
@@ -77,7 +78,6 @@ class Spot:
|
||||
de_latitude: float = None
|
||||
de_longitude: float = None
|
||||
|
||||
|
||||
# General QSO info
|
||||
|
||||
# Reported mode, such as SSB, PHONE, CW, FT8...
|
||||
@@ -95,7 +95,6 @@ class Spot:
|
||||
# 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
|
||||
@@ -109,7 +108,6 @@ class Spot:
|
||||
# Activation score. SOTA only
|
||||
activation_score: int = None
|
||||
|
||||
|
||||
# Display guidance (optional)
|
||||
|
||||
# Icon, from the Font Awesome set. This is fairly opinionated but is here to help the Spothole web UI and Field
|
||||
@@ -120,7 +118,6 @@ class Spot:
|
||||
band_color: str = None
|
||||
band_contrast_color: str = None
|
||||
|
||||
|
||||
# Timing info
|
||||
|
||||
# Time of the spot, UTC seconds since UNIX epoch
|
||||
@@ -134,7 +131,6 @@ class Spot:
|
||||
# Time that this software received the spot, ISO 8601
|
||||
received_time_iso: str = None
|
||||
|
||||
|
||||
# Source info
|
||||
|
||||
# Where we got the spot from, e.g. "POTA", "Cluster"...
|
||||
@@ -236,6 +232,19 @@ class Spot:
|
||||
if self.dx_latitude:
|
||||
self.dx_location_source = "SPOT"
|
||||
|
||||
# WAB/WAI grid to lat/lon
|
||||
if not self.dx_latitude and self.sig and self.sig_refs and len(self.sig_refs) > 0 and (
|
||||
self.sig == "WAB" or self.sig == "WAI"):
|
||||
ll = wab_wai_square_to_lat_lon(self.sig_refs[0])
|
||||
if ll:
|
||||
self.dx_latitude = ll[0]
|
||||
self.dx_longitude = ll[1]
|
||||
try:
|
||||
self.dx_grid = latlong_to_locator(self.dx_latitude, self.dx_longitude, 8)
|
||||
except:
|
||||
logging.debug("Invalid lat/lon received from WAB/WAI grid")
|
||||
self.dx_location_source = "WAB/WAI GRID"
|
||||
|
||||
# QRT comment detection
|
||||
if self.comment and not self.qrt:
|
||||
self.qrt = "QRT" in self.comment.upper()
|
||||
@@ -272,7 +281,7 @@ 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_location_source == "SPOT" or (
|
||||
self.dx_location_good = self.dx_location_source == "SPOT" or self.dx_location_source == "WAB/WAI GRID" or (
|
||||
self.dx_location_source == "QRZ" and not "/" in self.dx_call)
|
||||
|
||||
# DE of "RBNHOLE", "SOTAMAT" and "ZLOTA" are not things we can look up location for
|
||||
|
||||
Reference in New Issue
Block a user