Check pyhamtools callinfo for lat/Lon of DXCC from static country info as a last resort. Closes #13

This commit is contained in:
Ian Renton
2025-09-29 20:19:01 +01:00
parent cd575e7ed2
commit 60314c7d44
3 changed files with 53 additions and 7 deletions

View File

@@ -8,7 +8,8 @@ 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_mode_from_comment, infer_name_from_callsign, infer_latlon_from_callsign, infer_grid_from_callsign
infer_mode_from_comment, infer_name_from_callsign, infer_latlon_from_callsign_dxcc, infer_grid_from_callsign_dxcc, \
infer_latlon_from_callsign_qrz, infer_grid_from_callsign_qrz
# Data class that defines a spot.
@@ -76,6 +77,10 @@ class Spot:
# Latitude & longitude, in degrees. This could be from a geographical reference e.g. POTA, or from a QRZ lookup
latitude: float = None
longitude: float = None
# Location source. Indicates how accurate the location might be. Values: "SPOT", "QRZ, "DXCC", "NONE"
location_source: str = None
# Location good. Indicates that the software thinks the location data is good enough to plot on a map.
location_good: bool = None
# QRT state. Some APIs return spots marked as QRT. Otherwise we can check the comments.
qrt: bool = None
# Where we got the spot from, e.g. "POTA", "Cluster"...
@@ -129,6 +134,8 @@ class Spot:
self.longitude = ll[1]
if self.latitude and self.longitude and not self.grid:
self.grid = latlong_to_locator(self.latitude, self.longitude, 8)
if self.latitude:
self.location_source = "SPOT"
# QRT comment detection
if self.comment and not self.qrt:
@@ -140,12 +147,24 @@ class Spot:
if self.dx_call and not self.dx_name:
self.dx_name = infer_name_from_callsign(self.dx_call)
if self.dx_call and not self.latitude:
latlon = infer_latlon_from_callsign(self.dx_call)
latlon = infer_latlon_from_callsign_qrz(self.dx_call)
if latlon:
self.latitude = latlon[0]
self.longitude = latlon[1]
if self.dx_call and not self.grid:
self.grid = infer_grid_from_callsign(self.dx_call)
self.grid = infer_grid_from_callsign_qrz(self.dx_call)
self.location_source = "QRZ"
# Last resort for getting a position, use the DXCC entity.
if self.dx_call and not self.latitude:
latlon = infer_latlon_from_callsign_dxcc(self.dx_call)
self.latitude = latlon[0]
self.longitude = latlon[1]
self.grid = infer_grid_from_callsign_dxcc(self.dx_call)
self.location_source = "DXCC"
# 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.location_good = self.location_source == "SPOT" or (self.location_source == "QRZ" and not "/" in self.dx_call)
# JSON serialise
def to_json(self):