consbio / mbgl-renderer

Static renderer for Mapbox GL
MIT License
221 stars 63 forks source link

PMTiles support #98

Open halset opened 1 year ago

halset commented 1 year ago

It would be very nice to have support for PMTiles directly in mbgl-renderer with pmtiles://-urls. Should this wait for maplibre-support for mbgl-renderer og just be a new way to handle this new url scheme in the javascript part?

brendan-ward commented 1 year ago

This is a good idea for the long term (short term we need #95 first), thank you for the suggestion.

I'm not yet familiar enough with PMTiles to know quite how this would be implemented. I imagine support is coming at some point to maplibre-gl-native but I don't think it is there yet (correct me if I'm wrong). It may be that we register it to the NodeJS bindings like any other tileset, but then we have to add the extra logic to resolve individually addressed tiles to HTTP range requests against a PMTiles dataset (if I understand correctly). We'd have to fetch some metadata at the outset for each PMTiles to be able to do that resolving.

bdon commented 1 year ago

This might be possible without migrating to MapLibre - it's not clear for me that there's a pathway to add addProtocol-like functionality which exists in GL JS, as Native lacks arbitrary runtime extension points from what I understand.

But you may be able to adapt https://github.com/consbio/mbgl-renderer/blob/master/src/render.js#L250 to use the Browser/Node PMTiles decoder: https://github.com/protomaps/PMTiles/tree/main/js - this handles resolving Z/X/Y to ranges, maintaining an LRU cache of those intermediate parts, and decompressing responses.

brendan-ward commented 1 year ago

Thanks for the suggestions @bdon, greatly appreciated!

jeffreysfridge commented 1 year ago

Any updates on pmtiles support?

brendan-ward commented 1 year ago

No updates other than that I have no availability or short term plans to implement PMTiles support.

halset commented 10 months ago

Perhaps this will be handled by maplibre-native. https://github.com/maplibre/maplibre-native/issues/1978