mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-12-16 17:13:39 +00:00
Compare commits
3 Commits
e61d7bedb4
...
2ccfa28119
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ccfa28119 | ||
|
|
b313735e28 | ||
|
|
bbaa3597f6 |
@@ -301,7 +301,7 @@ class LookupHelper:
|
|||||||
return ituz
|
return ituz
|
||||||
|
|
||||||
# Infer an operator name from a callsign (requires QRZ.com/HamQTH)
|
# 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)
|
data = self.get_qrz_data_for_callsign(call)
|
||||||
if data and "fname" in data:
|
if data and "fname" in data:
|
||||||
name = data["fname"]
|
name = data["fname"]
|
||||||
@@ -315,7 +315,7 @@ class LookupHelper:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Infer a latitude and longitude from a callsign (requires QRZ.com/HamQTH)
|
# 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)
|
data = self.get_qrz_data_for_callsign(call)
|
||||||
if data and "latitude" in data and "longitude" in data:
|
if data and "latitude" in data and "longitude" in data:
|
||||||
return [data["latitude"], data["longitude"]]
|
return [data["latitude"], data["longitude"]]
|
||||||
@@ -326,7 +326,7 @@ class LookupHelper:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Infer a grid locator from a callsign (requires QRZ.com/HamQTH)
|
# 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)
|
data = self.get_qrz_data_for_callsign(call)
|
||||||
if data and "locator" in data:
|
if data and "locator" in data:
|
||||||
return data["locator"]
|
return data["locator"]
|
||||||
@@ -336,6 +336,17 @@ class LookupHelper:
|
|||||||
else:
|
else:
|
||||||
return None
|
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)
|
# Infer a latitude and longitude from a callsign (using DXCC, probably very inaccurate)
|
||||||
def infer_latlon_from_callsign_dxcc(self, call):
|
def infer_latlon_from_callsign_dxcc(self, call):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -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.latitude = data["latitude"] if "latitude" in data else None
|
||||||
sig_ref.longitude = data["longitude"] if "longitude" in data else None
|
sig_ref.longitude = data["longitude"] if "longitude" in data else None
|
||||||
elif sig.upper() == "WWFF":
|
elif sig.upper() == "WWFF":
|
||||||
|
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.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":
|
elif sig.upper() == "SIOTA":
|
||||||
siota_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv",
|
siota_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv",
|
||||||
headers=HTTP_HEADERS)
|
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.grid = row["LOCATOR"] if "LOCATOR" in row else None
|
||||||
sig_ref.latitude = float(row["LAT"]) if "LAT" 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
|
sig_ref.longitude = float(row["LNG"]) if "LNG" in row else None
|
||||||
|
break
|
||||||
elif sig.upper() == "WOTA":
|
elif sig.upper() == "WOTA":
|
||||||
data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.wota.org.uk/mapping/data/summits.json",
|
data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.wota.org.uk/mapping/data/summits.json",
|
||||||
headers=HTTP_HEADERS).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.grid = feature["properties"]["qthLocator"]
|
||||||
sig_ref.latitude = feature["geometry"]["coordinates"][1]
|
sig_ref.latitude = feature["geometry"]["coordinates"][1]
|
||||||
sig_ref.longitude = feature["geometry"]["coordinates"][0]
|
sig_ref.longitude = feature["geometry"]["coordinates"][0]
|
||||||
|
break
|
||||||
elif sig.upper() == "ZLOTA":
|
elif sig.upper() == "ZLOTA":
|
||||||
data = SEMI_STATIC_URL_DATA_CACHE.get("https://ontheair.nz/assets/assets.json", headers=HTTP_HEADERS).json()
|
data = SEMI_STATIC_URL_DATA_CACHE.get("https://ontheair.nz/assets/assets.json", headers=HTTP_HEADERS).json()
|
||||||
if data:
|
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.grid = latlong_to_locator(asset["y"], asset["x"], 6)
|
||||||
sig_ref.latitude = asset["y"]
|
sig_ref.latitude = asset["y"]
|
||||||
sig_ref.longitude = asset["x"]
|
sig_ref.longitude = asset["x"]
|
||||||
|
break
|
||||||
elif sig.upper() == "BOTA":
|
elif sig.upper() == "BOTA":
|
||||||
if not sig_ref.name:
|
if not sig_ref.name:
|
||||||
sig_ref.name = sig_ref.id
|
sig_ref.name = sig_ref.id
|
||||||
|
|||||||
@@ -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 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.
|
# the one from the park reference they're at.
|
||||||
if self.dx_calls and not self.dx_names:
|
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
|
# 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
|
# to a map, which as a byproduct avoids us having multiple duplicate copies of the object that are identical
|
||||||
|
|||||||
22
data/spot.py
22
data/spot.py
@@ -27,6 +27,9 @@ class Spot:
|
|||||||
dx_call: str = None
|
dx_call: str = None
|
||||||
# Name of the operator that has been spotted
|
# Name of the operator that has been spotted
|
||||||
dx_name: str = None
|
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
|
# Country of the DX operator
|
||||||
dx_country: str = None
|
dx_country: str = None
|
||||||
# Country flag of the DX operator
|
# 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 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.
|
# the one from the park reference they're at.
|
||||||
if self.dx_call and not self.dx_name:
|
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:
|
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:
|
if latlon:
|
||||||
self.dx_latitude = latlon[0]
|
self.dx_latitude = latlon[0]
|
||||||
self.dx_longitude = latlon[1]
|
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"
|
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.
|
# Last resort for getting a DX position, use the DXCC entity.
|
||||||
if self.dx_call and not self.dx_latitude:
|
if self.dx_call and not self.dx_latitude:
|
||||||
latlon = lookup_helper.infer_latlon_from_callsign_dxcc(self.dx_call)
|
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"):
|
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.
|
# DE operator position lookup, using QRZ.com.
|
||||||
if not self.de_latitude:
|
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:
|
if latlon:
|
||||||
self.de_latitude = latlon[0]
|
self.de_latitude = latlon[0]
|
||||||
self.de_longitude = latlon[1]
|
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.
|
# Last resort for getting a DE position, use the DXCC entity.
|
||||||
if not self.de_latitude:
|
if not self.de_latitude:
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ class WebServer:
|
|||||||
return self.serve_api({
|
return self.serve_api({
|
||||||
"call": call,
|
"call": call,
|
||||||
"name": fake_spot.dx_name,
|
"name": fake_spot.dx_name,
|
||||||
|
"qth": fake_spot.dx_qth,
|
||||||
"country": fake_spot.dx_country,
|
"country": fake_spot.dx_country,
|
||||||
"flag": fake_spot.dx_flag,
|
"flag": fake_spot.dx_flag,
|
||||||
"continent": fake_spot.dx_continent,
|
"continent": fake_spot.dx_continent,
|
||||||
|
|||||||
@@ -518,6 +518,10 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
description: Name of the operator
|
description: Name of the operator
|
||||||
example: Ian
|
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:
|
country:
|
||||||
type: string
|
type: string
|
||||||
description: Country of the operator
|
description: Country of the operator
|
||||||
@@ -745,6 +749,10 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
description: Name of the operator that has been spotted
|
description: Name of the operator that has been spotted
|
||||||
example: Ian
|
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:
|
dx_country:
|
||||||
type: string
|
type: string
|
||||||
description: Country of the DX operator
|
description: Country of the DX operator
|
||||||
|
|||||||
Reference in New Issue
Block a user