diff options
| author | Claude <noreply@anthropic.com> | 2026-04-09 09:43:49 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-04-09 09:43:49 +0000 |
| commit | 0a0b3afc080954a70526cc3e057bede1e704420b (patch) | |
| tree | 37fcdc186844812c0a2680897ecba875b2d8a36f /android-app | |
| parent | c0ad3c556d8a41fb934c34fd158e1e54e899f09b (diff) | |
fix(build): replace LatLngBounds properties with VisibleRegion corners
LatLngBounds.latSouth/latNorth/lonWest/lonEast don't exist in
MapLibre 13.0.1. Derive bounds from VisibleRegion corner LatLng
points (.nearLeft/.nearRight/.farLeft/.farRight) which are stable
across SDK versions.
Fixes CI compilation failure in MainActivity and ParticleWindView.
https://claude.ai/code/session_01HXPjBsogsJVRwCiekDGkJX
Diffstat (limited to 'android-app')
| -rw-r--r-- | android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt | 9 | ||||
| -rw-r--r-- | android-app/app/src/main/kotlin/org/terst/nav/ui/map/ParticleWindView.kt | 22 |
2 files changed, 16 insertions, 15 deletions
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt index f84e5fb..ad5746d 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt @@ -327,11 +327,10 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { } maplibreMap.addOnCameraIdleListener { - val bounds = maplibreMap.projection.visibleRegion.latLngBounds - viewModel.loadWindGrid( - bounds.latSouth, bounds.latNorth, - bounds.lonWest, bounds.lonEast - ) + val r = maplibreMap.projection.visibleRegion + val lats = listOf(r.nearLeft.latitude, r.nearRight.latitude, r.farLeft.latitude, r.farRight.latitude) + val lons = listOf(r.nearLeft.longitude, r.nearRight.longitude, r.farLeft.longitude, r.farRight.longitude) + viewModel.loadWindGrid(lats.min(), lats.max(), lons.min(), lons.max()) } maplibreMap.addOnMapLongClickListener { _ -> diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/map/ParticleWindView.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/map/ParticleWindView.kt index 0169fc1..d24d11c 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/ui/map/ParticleWindView.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/map/ParticleWindView.kt @@ -73,11 +73,11 @@ class ParticleWindView @JvmOverloads constructor( else ((now - lastFrameNs) / 1_000_000_000f).coerceAtMost(0.05f) lastFrameNs = now - val bounds = m.projection.visibleRegion.latLngBounds - val latSouth = bounds.latSouth.toFloat() - val latNorth = bounds.latNorth.toFloat() - val lonWest = bounds.lonWest.toFloat() - val lonEast = bounds.lonEast.toFloat() + val r = m.projection.visibleRegion + val latSouth = minOf(r.nearLeft.latitude, r.nearRight.latitude, r.farLeft.latitude, r.farRight.latitude).toFloat() + val latNorth = maxOf(r.nearLeft.latitude, r.nearRight.latitude, r.farLeft.latitude, r.farRight.latitude).toFloat() + val lonWest = minOf(r.nearLeft.longitude, r.nearRight.longitude, r.farLeft.longitude, r.farRight.longitude).toFloat() + val lonEast = maxOf(r.nearLeft.longitude, r.nearRight.longitude, r.farLeft.longitude, r.farRight.longitude).toFloat() val latRange = latNorth - latSouth val lonRange = lonEast - lonWest @@ -137,11 +137,13 @@ class ParticleWindView @JvmOverloads constructor( // ── Helpers ────────────────────────────────────────────────────────────── private fun scatter(m: MapLibreMap) { - val bounds = m.projection.visibleRegion.latLngBounds - val latSouth = bounds.latSouth.toFloat() - val lonWest = bounds.lonWest.toFloat() - val latRange = (bounds.latNorth - latSouth).toFloat() - val lonRange = (bounds.lonEast - lonWest).toFloat() + val r = m.projection.visibleRegion + val latSouth = minOf(r.nearLeft.latitude, r.nearRight.latitude, r.farLeft.latitude, r.farRight.latitude).toFloat() + val latNorth = maxOf(r.nearLeft.latitude, r.nearRight.latitude, r.farLeft.latitude, r.farRight.latitude).toFloat() + val lonWest = minOf(r.nearLeft.longitude, r.nearRight.longitude, r.farLeft.longitude, r.farRight.longitude).toFloat() + val lonEast = maxOf(r.nearLeft.longitude, r.nearRight.longitude, r.farLeft.longitude, r.farRight.longitude).toFloat() + val latRange = latNorth - latSouth + val lonRange = lonEast - lonWest for (i in 0 until N) { particleLat[i] = latSouth + Random.nextFloat() * latRange particleLon[i] = lonWest + Random.nextFloat() * lonRange |
