From ab22244f8645b90a22c686fc131eed402a7dd29d Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Tue, 8 Sep 2026 03:19:40 +0800 Subject: [PATCH] fix(map): grid-mode field center offset by -90/-180 base Maidenhead field index 0 spans -90..-80 lat / -180..-160 lon, so the field-center must subtract those bases. Without them, entering grid mode centered a hemisphere away (OL62 -> 115N/290E instead of 25N/110E). --- .../java/com/rtbishop/look4sat/feature/map/MapScreen.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MapScreen.kt b/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MapScreen.kt index 54baa79b..28cbc4a1 100644 --- a/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MapScreen.kt +++ b/feature/map/src/main/java/com/rtbishop/look4sat/feature/map/MapScreen.kt @@ -503,10 +503,14 @@ private fun setGridMode( val pos = stationPosition ?: return val lat = pos.latitude val lon = pos.longitude + // Maidenhead field indices: field 0 spans -90..-80° lat and + // -180..-160° lon, so the field-center must be offset by those + // bases — omitting them maps e.g. OL62's field center to + // 115°N/290°E (an ocean a hemisphere away) instead of 25°N/110°E. val fieldLat = ((lat + 90.0) / 10.0).toInt().coerceIn(0, 17) val fieldLon = ((lon + 180.0) / 20.0).toInt().coerceIn(0, 17) - val centerLat = fieldLat * 10.0 + 5.0 - val centerLon = fieldLon * 20.0 + 10.0 + val centerLat = fieldLat * 10.0 + 5.0 - 90.0 + val centerLon = fieldLon * 20.0 + 10.0 - 180.0 mapView.post { mapView.controller.setCenter(GeoPoint(centerLat, centerLon)) } } } catch (e: Exception) {