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

Add PMTiles support #938

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add PMTiles support #938

wants to merge 3 commits into from

Conversation

pka
Copy link

@pka pka commented Sep 19, 2024

Add support for pmtiles sources. Solves #807

There is still an error, probably when adding the source to the Maputnik sources:
Failed to process sources for 'pmtiles://https://example.com/data/switzerland.pmtiles' TypeError: NetworkError when attempting to fetch resource.
    fetchSources App.tsx:642

@bdon How did you solve this for https://editor.protomaps.com/ ?

@HarelM
Copy link
Collaborator

HarelM commented Sep 19, 2024

Thanks for taking the time to open this PR.
Please see my comments in the linked issue.
This part of the solution is a simple one, I would be more interested in actually looking at the problem from a UX perspective and trying to solve that and not just add the pmtiles plugin...

@pka
Copy link
Author

pka commented Sep 19, 2024

I saw your comment there, but comparing PMTiles with MBTiles didn't make sense for me. PMTiles can be used as local and remote datasource like mvt files when using an HTTP server with Range Request support.

@HarelM
Copy link
Collaborator

HarelM commented Sep 19, 2024

But you still need a http server with range support... From my point if view using a tile server or worker is not a big lift.
Moreover, since this is not supported for native it will create a style that might not work, which is not a great experience...

@pka
Copy link
Author

pka commented Sep 19, 2024

There are not many HTTP servers without Range Request support (python -m http.server comes to my mind) and serving a tileset from a very compact single file without an additional tile server makes hosting a lot easier.

Switching the tile source in a style created with Maputnik is a one-liner like jq '.sources.mysource.url="pmtiles:///mytiles.pmtiles" | del(.sources.mysource.tiles)' mystyle.json. The style itself is the same for any platform.

@HarelM
Copy link
Collaborator

HarelM commented Sep 19, 2024

I could argue that you won't need to run the above script at all and using Martin or tileserver-gl (using docker, or even without) is not that complicated...
Bottom line, I don't feel comfortable with this feature as it is now from a UX perspective (not a technical one).
But if someone else from the maintainers want to approve it, I won't object.

@kevinschaul
Copy link
Collaborator

@pka It might be helpful if you could write your full use-case in #807. Where is the pmtiles file you want to reference? Is it on your local machine or hosted somewhere?

For background I also use maputnik + PMTiles but with a separate tool that runs both. If we can all share our use-cases, that could help reveal pain points and potential solutions.

@pka
Copy link
Author

pka commented Sep 20, 2024

@nyurik @lseelenbinder Could you maybe help formulating use cases for styling maps with PMTiles storage?

* add PMTiles mode to source editing dialog
* App.tsx detects PMTiles sources for fetching vector_layers (inspect does not yet work)
@bdon
Copy link

bdon commented Sep 22, 2024

@bdon How did you solve this for https://editor.protomaps.com/ ?

here is the necessary changes to add PMTiles for vector sources to the UI:

bdon/maputnik@8ac5e36

This works fine with remote sources e.g. you can paste in https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles and then reference the layer called water

However, the "inspect" panel doesn't work yet because it relies on MapLibre internals to fetch TileJSON. The inspect panel will work once protomaps/PMTiles#247 is implemented.

(EDIT: I implemented 247 above, so inspect works now.)

@pka pka marked this pull request as ready for review September 25, 2024 20:43
@bdon
Copy link

bdon commented Sep 26, 2024

There is a UI issue right now where the pmtiles:// prefix sometimes appears in the modal data sources editor, sometime does not. Ideally the pmtiles:// prefix is totally hidden from the editor, letting you naturally input a HTTP or HTTPS URL of a .pmtiles archive, and the internal Style JSON state has the full pmtiles://https://... string. This requires some changes to the existing patches, PR welcome.

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

Successfully merging this pull request may close these issues.

4 participants