From 6e7ffd626e62ed82877a35ec5853a7e82298ed79 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 14 Feb 2026 07:47:02 +0000 Subject: [PATCH] Fix CQ/ITU lookups for zones that cross the antemeridian --- core/geo_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/geo_utils.py b/core/geo_utils.py index ce0cbf2..88a4661 100644 --- a/core/geo_utils.py +++ b/core/geo_utils.py @@ -40,11 +40,21 @@ def lat_lon_to_cq_zone(lat, lon): # Finds out which ITU zone a lat/lon point is in. def lat_lon_to_itu_zone(lat, lon): + lon = ((lon + 180) % 360) - 180 for index, row in itu_zone_data.iterrows(): polygon = Polygon(row["geometry"]) test_point = Point(lon, lat) if polygon.contains(test_point): return int(row["name"]) + + # Might have problems around the antemeridian, so if we didn't find a match, try offsetting the point by + or - + # 360 degrees longitude to try the other side of the Earth + if lon < 0: + test_point = Point(lon + 360, lat) + else: + test_point = Point(lon - 360, lat) + if polygon.contains(test_point): + return int(row["name"]) return None