mbgl-renderer icon indicating copy to clipboard operation
mbgl-renderer copied to clipboard

PMTiles support

Open halset opened this issue 2 years ago • 6 comments

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?

halset avatar Jan 12 '23 11:01 halset

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.

brendan-ward avatar Jan 12 '23 16:01 brendan-ward

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.

bdon avatar Feb 07 '23 06:02 bdon

Thanks for the suggestions @bdon, greatly appreciated!

brendan-ward avatar Feb 07 '23 18:02 brendan-ward

Any updates on pmtiles support?

jeffreysfridge avatar Sep 10 '23 15:09 jeffreysfridge

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

brendan-ward avatar Sep 11 '23 15:09 brendan-ward

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

halset avatar Jan 19 '24 10:01 halset