mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Set up status and start working on filters panel #7
This commit is contained in:
@@ -38,7 +38,7 @@ def infer_mode_type_from_mode(mode):
|
||||
logging.warn("Found an unrecognised mode: " + mode + ". Developer should categorise this.")
|
||||
return None
|
||||
|
||||
# Infer a band from a frequency in kHz
|
||||
# Infer a band from a frequency in Hz
|
||||
def infer_band_from_freq(freq):
|
||||
for b in BANDS:
|
||||
if b.start_freq <= freq <= b.end_freq:
|
||||
@@ -126,10 +126,13 @@ def infer_grid_from_callsign_qrz(call):
|
||||
|
||||
# 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:
|
||||
try:
|
||||
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
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
# Infer a grid locator from a callsign (using DXCC, probably very inaccurate)
|
||||
@@ -138,9 +141,12 @@ def infer_grid_from_callsign_dxcc(call):
|
||||
return latlong_to_locator(latlon[0], latlon[1], 8)
|
||||
|
||||
|
||||
# Infer a mode from the frequency according to the band plan. Just a guess really.
|
||||
# Infer a mode from the frequency (in Hz) according to the band plan. Just a guess really.
|
||||
def infer_mode_from_frequency(freq):
|
||||
return freq_to_band(freq)["mode"]
|
||||
try:
|
||||
return freq_to_band(freq / 1000.0)["mode"]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
|
||||
# Convert objects to serialisable things. Used by JSON serialiser as a default when it encounters unserializable things.
|
||||
|
||||
Reference in New Issue
Block a user