From 555a8418a9d793390e214947f7be32e73b5cae72 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 25 Jul 2026 15:27:13 +0100 Subject: [PATCH] Fix IOTA location lookup --- core/sig_utils.py | 13 +++++++++++-- templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/core/sig_utils.py b/core/sig_utils.py index 2dec186..253c841 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -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: diff --git a/templates/add_spot.html b/templates/add_spot.html index c647075..71ff126 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -76,7 +76,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index f481f14..653a089 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -75,7 +75,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 56e3e49..bd304e2 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -75,8 +75,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index af05a27..906aa30 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -10,10 +10,10 @@ - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 92805ca..7790e03 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index d11f6eb..3286a46 100644 --- a/templates/map.html +++ b/templates/map.html @@ -108,8 +108,8 @@ - - + + diff --git a/templates/spots.html b/templates/spots.html index a77bf94..5d16f1a 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -116,8 +116,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 4f55f4d..3ca2975 100644 --- a/templates/status.html +++ b/templates/status.html @@ -59,7 +59,7 @@ - +