Fix IOTA location lookup

This commit is contained in:
Ian Renton
2026-07-25 15:27:13 +01:00
parent 7ee08e2fcd
commit 555a8418a9
9 changed files with 26 additions and 17 deletions
+11 -2
View File
@@ -104,8 +104,17 @@ def populate_sig_ref_info(sig_ref):
sig_ref.name = data["name"] if "name" in data else None
sig_ref.url = "https://www.cqgma.org/zinfo.php?ref=" + ref_id
sig_ref.grid = data["locator"] if "locator" 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
# For some things (just IOTA?) the GMA actually returns a box where "latitude" and "longitude" are
# the zeroest corner of the box, then "lat2" and "lng2" provide the other corner. We detect this
# and provide a single lat/lon for the centre. Otherwise if we don't have these extra parameters,
# just use the single point we have.
if "latitude" in data and "longitude" in data and "lat2" in data and "lng2" in data:
sig_ref.latitude = (float(data["latitude"]) + float(data["lat2"])) / 2.0
sig_ref.longitude = (float(data["longitude"]) + float(data["lng2"])) / 2.0
else:
sig_ref.latitude = float(data["latitude"]) if "latitude" in data else None
sig_ref.longitude = float(data["longitude"]) if "longitude" in data else None
elif not response.from_cache:
logging.warning("Malformed response looking up %s ref %s via GMA", sig, ref_id)
elif not response.from_cache: