Compare commits

...

3 Commits

Author SHA1 Message Date
Ian Renton
2ccfa28119 Get "qth" friendly name from QRZ/clublog and return in the callsign lookup. Closes #77 2025-11-02 20:51:16 +00:00
Ian Renton
b313735e28 Add missing break statements 2025-11-02 20:38:30 +00:00
Ian Renton
bbaa3597f6 Implement WWFF reference lookup. Closes #76 2025-11-02 20:37:30 +00:00
6 changed files with 55 additions and 10 deletions

View File

@@ -301,7 +301,7 @@ class LookupHelper:
return ituz
# Infer an operator name from a callsign (requires QRZ.com/HamQTH)
def infer_name_from_callsign(self, call):
def infer_name_from_callsign_online_lookup(self, call):
data = self.get_qrz_data_for_callsign(call)
if data and "fname" in data:
name = data["fname"]
@@ -315,7 +315,7 @@ class LookupHelper:
return None
# Infer a latitude and longitude from a callsign (requires QRZ.com/HamQTH)
def infer_latlon_from_callsign_qrz(self, call):
def infer_latlon_from_callsign_online_lookup(self, call):
data = self.get_qrz_data_for_callsign(call)
if data and "latitude" in data and "longitude" in data:
return [data["latitude"], data["longitude"]]
@@ -326,7 +326,7 @@ class LookupHelper:
return None
# Infer a grid locator from a callsign (requires QRZ.com/HamQTH)
def infer_grid_from_callsign_qrz(self, call):
def infer_grid_from_callsign_online_lookup(self, call):
data = self.get_qrz_data_for_callsign(call)
if data and "locator" in data:
return data["locator"]
@@ -336,6 +336,17 @@ class LookupHelper:
else:
return None
# Infer a textual QTH from a callsign (requires QRZ.com/HamQTH)
def infer_qth_from_callsign_online_lookup(self, call):
data = self.get_qrz_data_for_callsign(call)
if data and "addr2" in data:
return data["addr2"]
data = self.get_hamqth_data_for_callsign(call)
if data and "qth" in data:
return data["qth"]
else:
return None
# Infer a latitude and longitude from a callsign (using DXCC, probably very inaccurate)
def infer_latlon_from_callsign_dxcc(self, call):
try:

View File

@@ -69,7 +69,17 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.latitude = data["latitude"] if "latitude" in data else None
sig_ref.longitude = data["longitude"] if "longitude" in data else None
elif sig.upper() == "WWFF":
sig_ref.url = "https://wwff.co/directory/?showRef=" + sig_ref_id
wwff_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://wwff.co/wwff-data/wwff_directory.csv",
headers=HTTP_HEADERS)
wwff_dr = csv.DictReader(wwff_csv_data.content.decode().splitlines())
for row in wwff_dr:
if row["reference"] == sig_ref_id:
sig_ref.name = row["name"] if "name" in row else None
sig_ref.url = "https://wwff.co/directory/?showRef=" + sig_ref_id
sig_ref.grid = row["iaruLocator"] if "iaruLocator" in row else None
sig_ref.latitude = float(row["latitude"]) if "latitude" in row else None
sig_ref.longitude = float(row["longitude"]) if "longitude" in row else None
break
elif sig.upper() == "SIOTA":
siota_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv",
headers=HTTP_HEADERS)
@@ -80,6 +90,7 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.grid = row["LOCATOR"] if "LOCATOR" in row else None
sig_ref.latitude = float(row["LAT"]) if "LAT" in row else None
sig_ref.longitude = float(row["LNG"]) if "LNG" in row else None
break
elif sig.upper() == "WOTA":
data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.wota.org.uk/mapping/data/summits.json",
headers=HTTP_HEADERS).json()
@@ -91,6 +102,7 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.grid = feature["properties"]["qthLocator"]
sig_ref.latitude = feature["geometry"]["coordinates"][1]
sig_ref.longitude = feature["geometry"]["coordinates"][0]
break
elif sig.upper() == "ZLOTA":
data = SEMI_STATIC_URL_DATA_CACHE.get("https://ontheair.nz/assets/assets.json", headers=HTTP_HEADERS).json()
if data:
@@ -101,6 +113,7 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6)
sig_ref.latitude = asset["y"]
sig_ref.longitude = asset["x"]
break
elif sig.upper() == "BOTA":
if not sig_ref.name:
sig_ref.name = sig_ref.id

View File

@@ -121,7 +121,7 @@ class Alert:
# 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.
if self.dx_calls and not self.dx_names:
self.dx_names = list(map(lambda c: lookup_helper.infer_name_from_callsign(c), self.dx_calls))
self.dx_names = list(map(lambda c: lookup_helper.infer_name_from_callsign_online_lookup(c), self.dx_calls))
# Always create an ID based on a hash of every parameter *except* received_time. This is used as the index
# to a map, which as a byproduct avoids us having multiple duplicate copies of the object that are identical

View File

@@ -27,6 +27,9 @@ class Spot:
dx_call: str = None
# Name of the operator that has been spotted
dx_name: str = 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
# Country of the DX operator
dx_country: str = None
# Country flag of the DX operator
@@ -313,15 +316,24 @@ class Spot:
# the actual spotting 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.
if self.dx_call and not self.dx_name:
self.dx_name = lookup_helper.infer_name_from_callsign(self.dx_call)
self.dx_name = lookup_helper.infer_name_from_callsign_online_lookup(self.dx_call)
if self.dx_call and not self.dx_latitude:
latlon = lookup_helper.infer_latlon_from_callsign_qrz(self.dx_call)
latlon = lookup_helper.infer_latlon_from_callsign_online_lookup(self.dx_call)
if latlon:
self.dx_latitude = latlon[0]
self.dx_longitude = latlon[1]
self.dx_grid = lookup_helper.infer_grid_from_callsign_qrz(self.dx_call)
self.dx_grid = lookup_helper.infer_grid_from_callsign_online_lookup(self.dx_call)
self.dx_location_source = "HOME QTH"
# Determine a "QTH" string. If we have a SIG ref, pick the first one and turn it into a suitable stirng,
# 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
if self.sig_refs[0].name:
self.dx_qth = self.dx_qth + " " + self.sig_refs[0].name
else:
self.dx_qth = lookup_helper.infer_qth_from_callsign_online_lookup(self.dx_call)
# Last resort for getting a DX position, use the DXCC entity.
if self.dx_call and not self.dx_latitude:
latlon = lookup_helper.infer_latlon_from_callsign_dxcc(self.dx_call)
@@ -341,11 +353,11 @@ class Spot:
if self.de_call and any(char.isdigit() for char in self.de_call) and not (self.de_call.startswith("T2") and self.source == "APRS-IS"):
# DE operator position lookup, using QRZ.com.
if not self.de_latitude:
latlon = lookup_helper.infer_latlon_from_callsign_qrz(self.de_call)
latlon = lookup_helper.infer_latlon_from_callsign_online_lookup(self.de_call)
if latlon:
self.de_latitude = latlon[0]
self.de_longitude = latlon[1]
self.de_grid = lookup_helper.infer_grid_from_callsign_qrz(self.de_call)
self.de_grid = lookup_helper.infer_grid_from_callsign_online_lookup(self.de_call)
# Last resort for getting a DE position, use the DXCC entity.
if not self.de_latitude:

View File

@@ -127,6 +127,7 @@ class WebServer:
return self.serve_api({
"call": call,
"name": fake_spot.dx_name,
"qth": fake_spot.dx_qth,
"country": fake_spot.dx_country,
"flag": fake_spot.dx_flag,
"continent": fake_spot.dx_continent,

View File

@@ -518,6 +518,10 @@ paths:
type: string
description: Name of the operator
example: Ian
qth:
type: string
description: QTH of the operator. This could be from any SIG refs or could be from online lookup of their home QTH.
example: Dorset
country:
type: string
description: Country of the operator
@@ -745,6 +749,10 @@ components:
type: string
description: Name of the operator that has been spotted
example: Ian
dx_qth:
type: string
description: 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.
example: Dorset
dx_country:
type: string
description: Country of the DX operator