mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Check pyhamtools callinfo for lat/Lon of DXCC from static country info as a last resort. Closes #13
This commit is contained in:
@@ -2,6 +2,7 @@ import logging
|
||||
from datetime import datetime
|
||||
|
||||
from pyhamtools import LookupLib, Callinfo
|
||||
from pyhamtools.locator import latlong_to_locator
|
||||
|
||||
from core.config import config
|
||||
from core.constants import BANDS, UNKNOWN_BAND, CW_MODES, PHONE_MODES, DATA_MODES, ALL_MODES
|
||||
@@ -105,21 +106,34 @@ def infer_name_from_callsign(call):
|
||||
return None
|
||||
|
||||
# Infer a latitude and longitude from a callsign (requires QRZ.com)
|
||||
def infer_latlon_from_callsign(call):
|
||||
def infer_latlon_from_callsign_qrz(call):
|
||||
data = get_qrz_data_for_callsign(call)
|
||||
if data and "latitude" in data and "longitude" in data:
|
||||
return [data["longitude"], data["longitude"]]
|
||||
return [data["latitude"], data["longitude"]]
|
||||
else:
|
||||
return None
|
||||
|
||||
# Infer a grid locator from a callsign (requires QRZ.com)
|
||||
def infer_grid_from_callsign(call):
|
||||
def infer_grid_from_callsign_qrz(call):
|
||||
data = get_qrz_data_for_callsign(call)
|
||||
if data and "locator" in data:
|
||||
return data["locator"]
|
||||
else:
|
||||
return None
|
||||
|
||||
# Infer a latitude and longitude from a callsign (using DXCC, probably very inaccurate)
|
||||
def infer_latlon_from_callsign_dxcc(call):
|
||||
data = CALL_INFO_BASIC.get_lat_long(call)
|
||||
if data and "latitude" in data and "longitude" in data:
|
||||
return [data["latitude"], data["longitude"]]
|
||||
else:
|
||||
return None
|
||||
|
||||
# Infer a grid locator from a callsign (using DXCC, probably very inaccurate)
|
||||
def infer_grid_from_callsign_dxcc(call):
|
||||
latlon = infer_latlon_from_callsign_dxcc(call)
|
||||
return latlong_to_locator(latlon[0], latlon[1], 8)
|
||||
|
||||
|
||||
# Convert objects to serialisable things. Used by JSON serialiser as a default when it encounters unserializable things.
|
||||
# Converts datetimes to ISO.
|
||||
|
||||
Reference in New Issue
Block a user