From 366edd8bbbbd2ff4cb9c34e89e261a87a246a04f Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Mon, 7 Sep 2026 06:01:10 +0800 Subject: [PATCH] fix: correct longitude bounds in Maidenhead grid overlay (left/right were swapped, so meridians and worked-grid fills never drew) --- .../look4sat/feature/map/MaidenheadGridOverlay.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MaidenheadGridOverlay.kt b/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MaidenheadGridOverlay.kt index fc153a06..2d2dd785 100644 --- a/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MaidenheadGridOverlay.kt +++ b/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MaidenheadGridOverlay.kt @@ -25,6 +25,8 @@ import org.osmdroid.views.Projection import org.osmdroid.views.overlay.Overlay import kotlin.math.ceil import kotlin.math.floor +import kotlin.math.max +import kotlin.math.min /** * Maidenhead locator grid overlay, drawn directly on the map canvas. @@ -71,10 +73,10 @@ class MaidenheadGridOverlay : Overlay() { // Visible bounding box in geographic coordinates val north = projection.fromPixels(0, 0) val south = projection.fromPixels(canvas.width, canvas.height) - val topLat = north.latitude.coerceIn(-90.0, 90.0) - val bottomLat = south.latitude.coerceIn(-90.0, 90.0) - val leftLon = south.longitude - val rightLon = north.longitude + val topLat = max(north.latitude, south.latitude).coerceIn(-90.0, 90.0) + val bottomLat = min(north.latitude, south.latitude).coerceIn(-90.0, 90.0) + val leftLon = min(north.longitude, south.longitude) + val rightLon = max(north.longitude, south.longitude) val firstRow = floor(bottomLat / cellLat).toInt() val lastRow = ceil(topLat / cellLat).toInt()