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

support PMTiles as a data source #776

Open
burritojustice opened this issue May 6, 2021 · 1 comment
Open

support PMTiles as a data source #776

burritojustice opened this issue May 6, 2021 · 1 comment

Comments

@burritojustice
Copy link

burritojustice commented May 6, 2021

Teach Tangram how to natively decipher 'serverless' PMTiles.

https://github.com/protomaps/PMTiles

"PMTiles is a single-file archive format for tiled data. A PMTiles archive can be hosted on a commodity storage platform such as S3, and enables low-cost, zero-maintenance map applications that are "serverless" - free of a custom tile backend or third party provider."

"PMTiles is a binary serialization format designed for two main access patterns: over the network, via HTTP 1.1 Byte Serving (Range: requests), or via memory-mapped files on disk."

via https://protomaps.com/blog/dynamic-maps-static-storage/

1. Fetch the first 512 kilobytes and parse the directory into a lookup table
2. Look up by key of the tile you want, in this case 8_65_95
3. It's a match! You'll have a byte range offset: 785366 length: 21400
4. Fetch those bytes using Range:bytes=785366-806765 and interpret the data

200 line JS decoder library: https://github.com/protomaps/PMTiles/blob/master/js/index.mjs

Perhaps something like

sources:
    mapzen:
        type: PMTiles
        url: https://mydata.com/map.pmtiles

though this does not give an indication of the tile type, which would likely be pbf or png given the environment.

@bdon
Copy link
Contributor

bdon commented Jun 19, 2021

+1

From what I can tell https://github.com/protomaps/PMTiles needs to be brought in as a dependency, because Tangram does not expose an API to extend sources at runtime, it's a small bit of code but fast moving at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants