-
Notifications
You must be signed in to change notification settings - Fork 176
Description
Is your feature request related to a problem? Please describe.
While doing a student-app-project mandatory APIs were on WMS EPSG3857 format. Seeing the general ease of use of the GoogleMap-composable and some previous knowledge I had about WMTS I figured I could just convert as I learned more about the WMS-format. Checking the network requests made by the MapLibre example provided to us I saw that it in fact did query the WMS-API in a square tile-based manner too.
Describe the solution you'd like
I have written code for:
A URL-tile provider subclass that takes a urlFormatter-lambda with arguments for the bounding-box (xMin,yMin,xMax,yMax) that returns a string, so that the programmer can dictate the formatting of the URLs sent from the tile provider to the tile overlay.
To make it efficient the provider uses bit shifting for powers of 2 used in BBOX calculations. (IE finding the amount of tiles across for a given zoom-level)
Another efficiency is that if given bounds of the API the overlay is showing, the provider will return null in place of URLs pointing to tiles outside of the APIs bounds foregoing a "doomed" network request.
I also wrote a TileOverlay-wrapper that sets up its own TileProvider, with the only requirement of a urlFormatter-lambda it can pass down to the provider.
Describe alternatives you've considered
Just providing a URL-tile provider subclass though why not give a working TileOverlay-wrapper too.
Letting programmers make this themselves when they need it.
Discouraging WMS use so that API-providers all start serving WMTS instead.
Additional context
This seems like something that could easily have been provided already so it would be interesting to hear why it isn't (as far as I could tell from my research). I have checked for distortion at high latitudes where it would be the most pronounced, but I can't detect any.
Here is the urlFormatter definition and how I pass it in my app:
In WmsUrlTileProvider constructor:
private val urlFormatter: (
xMinBound: Double,
yMinBound: Double,
xMaxBound: Double,
yMaxBound: Double
) -> String
The lambda I pass it as an argument:
val geologyApiUrlFormatter = { xMin: Double, yMin: Double, xMax: Double, yMax: Double ->
"$geologyApi$graniteLayer&BBOX=$xMin,$yMin,$xMax,$yMax" }