fix: correct longitude bounds in Maidenhead grid overlay (left/right were swapped, so meridians and worked-grid fills never drew)

This commit is contained in:
atsunatsu committed 2026-09-07 06:01:10 +08:00
1 parent 13df0dfcec
commit 366edd8bbb
1 file changed
+6 -4
@@ -25,6 +25,8 @@ import org.osmdroid.views.Projection
import org.osmdroid.views.overlay.Overlay import org.osmdroid.views.overlay.Overlay
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.floor import kotlin.math.floor
import kotlin.math.max
import kotlin.math.min
/** /**
* Maidenhead locator grid overlay, drawn directly on the map canvas. * Maidenhead locator grid overlay, drawn directly on the map canvas.
@@ -71,10 +73,10 @@ class MaidenheadGridOverlay : Overlay() {
// Visible bounding box in geographic coordinates // Visible bounding box in geographic coordinates
val north = projection.fromPixels(0, 0) val north = projection.fromPixels(0, 0)
val south = projection.fromPixels(canvas.width, canvas.height) val south = projection.fromPixels(canvas.width, canvas.height)
val topLat = north.latitude.coerceIn(-90.0, 90.0) val topLat = max(north.latitude, south.latitude).coerceIn(-90.0, 90.0)
val bottomLat = south.latitude.coerceIn(-90.0, 90.0) val bottomLat = min(north.latitude, south.latitude).coerceIn(-90.0, 90.0)
val leftLon = south.longitude val leftLon = min(north.longitude, south.longitude)
val rightLon = north.longitude val rightLon = max(north.longitude, south.longitude)
val firstRow = floor(bottomLat / cellLat).toInt() val firstRow = floor(bottomLat / cellLat).toInt()
val lastRow = ceil(topLat / cellLat).toInt() val lastRow = ceil(topLat / cellLat).toInt()