Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapLibreMap.getVisibleRegion(true).latLngBounds returns invalid coordinates #2951

Open
westnordost opened this issue Oct 21, 2024 · 0 comments
Labels
android bug Something isn't working

Comments

@westnordost
Copy link
Collaborator

Describe the bug
MapLibreMap.visibleRegion.latLngBounds in certain circumstances returns a LatLngBounds with an invalid longitude (e.g. longitude=422.6005507684057).

Related crash report:

java.lang.IllegalArgumentException: Latitude 89.99986064045117, longitude 422.6005507684057 is not a valid position
	at de.westnordost.streetcomplete.data.osm.mapdata.LatLon$Companion.checkValidity(Unknown Source:73)
	at de.westnordost.streetcomplete.data.osm.mapdata.LatLon.<init>(SourceFile:0)
	at de.westnordost.streetcomplete.data.osm.mapdata.BoundingBox.<init>(SourceFile:0)
	at de.westnordost.streetcomplete.screens.main.map.maplibre.PositionKt.toBoundingBox(Unknown Source:16)
	at de.westnordost.streetcomplete.screens.main.map.maplibre.PositionKt.screenAreaToBoundingBox(Unknown Source:16)
	at de.westnordost.streetcomplete.screens.main.map.MapFragment.getDisplayedArea(Unknown Source:4)

(MapFragment.getDisplayedArea() calls mapLibreMap.projection.getVisibleRegion(true).latLngBounds)

To Reproduce
Move the screen to overlap with the 180th meridian. Observe the result of VisibleRegion.latLngBounds.
Maybe there are other ways to reproduce this, too.

Expected behavior
LatLngBounds should always contain valid latitude and longitude coordinates.

Platform information:

  • Android
  • Maplibre v11.5.1

Additional context
Every VisibleRegion (= trapezoid of four LatLng coordinates at screen borders) has a LatLngBounds (= aligned rectangle of LatLng coordinates). A documentation comment states

since 7.0.0 LatLngBounds cannot be wrapped any more, i.e longitudeWest has to be less or equal to longitudeEast.

Fair enough, but then, what is the latLngBounds of a VisibleRegion at the 180th meridian? Looks to me that it should be two LatLngBounds in that case - one on the left and one on the right side of the 180th meridian.
In any case, currently, that documentation comment seems to be wrong anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants