Possibilities of extending the Maplibre-gl-js library while developing a weather application #3109
Replies: 2 comments 4 replies
-
I don't fully know what parts of maplibre would be helpful, but your can do a lot of stuff related to tiles with addProtocol. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am developing a weather application on top of Maplibre library as a custom WebGL renderer. I already have one fully working version combining radar, satellite, land, and country-borders layers (with some occasional bugs) and now I would like to rewrite it from scratch (to fix bugs, make the code cleaner, etc.). However, the current version of my application uses Maplibre only minimally (basically only for handling map events, everything else is implemented as a whole new renderer using CustomLayerInterface - as I inspected the code of MeteoBlue app, I found out, that they do it similarly).
The thing is that some parts of my app's functionality are duplicate with the code which is already part of Maplibre library (WebGL-related stuff, tile handling, etc.). So I was thinking about trying to rewrite the application in a way to reuse as much of Maplibre code as possible so that some of the new functionality I implement could be potentially integrated into Maplibre later. However I am not sure, whether it is possible, and if so, then where to start.
I did some rough code analysis of Maplibre and came out with two solutions:
i) Try to extend RasterTileSource and RasterTileLayer, since the weather data are tile-based rasters - however, I am not sure, how hard it would be and whether it is possible and a good approach.
ii) Stick with the old solution implementing the application using CustomLayerInterface and just use some minor parts of Maplibre somehow... However in this case I am aware of the need to implement a major part of the core functionality by myself again since some parts of Maplibre code are private functions and properties that should not be accessed from outer scope.
While developing the application using Maplibre components, I could also contribute some code to the library. For example, I was thinking about extending the RasterTileSource / RasterTileLayer to support custom fragment (and vertex) shaders (also that was the first thing I was trying to figure out when I was starting with the app implementation - did not find any solution so I started with the mentioned CustomLayerInterface and did all from scratch - including tile handling and all stuff, which is also implemented somewhere in Maplibre). I think that it would be great if one could supply a tile source parametric URL and fragment shader source, which renders the tile images with some custom transformation. The reason is that not in all cases the fetched images are meant to be directly rendered on screen - they need some color transform / pre-process.
To make it more clear, here are some functional requirements:
The current weather application uses the mentioned FRs as follows:
i) for rendering country borders (no raster transform needed),
ii) for rendering land (dual-channel data transform to quad-channel),
iii) for rendering radar and satellite (before the raster-data are rendered, they must be decoded, put into a composite, preprocessed, and interpolated based on time -- this could be done in the preRender method as fully custom functionality not related to Maplibre, because it performs multiple offscreen render passes. The final result could be read by the custom tile Fragment Shader as defined in ii) ),
iv) for some non-tile-based data
Based on the requirements, do you think that I should try to implement the renderer in a way that it extends the current Maplibre functionality, or it is too much specific problem that it would be better to implement it using CustomLAyerInterface and do not care about extending Maplibre?
Thank you for any recommendations :)
PS: Sorry for such a long post, it's hard to express myself and my thoughts.
Beta Was this translation helpful? Give feedback.
All reactions