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

PMTiles area download mechanism #2352

Open
wipfli opened this issue May 1, 2024 · 5 comments
Open

PMTiles area download mechanism #2352

wipfli opened this issue May 1, 2024 · 5 comments

Comments

@wipfli
Copy link
Contributor

wipfli commented May 1, 2024

Is your feature request related to a problem? Please describe.
I'm always frustrated when downloading tiles for offline usage is slow.

Describe the solution you'd like
The PMTiles storage format orders tiles that are on a Hilbert curve in space linearly in memory. As a consequence, tiles that are close together can be downloaded in only a few range requests whereas with traditional zxy endpoints each tile has to be downloaded individually.

So, area downloads of tiles for offline usage are much more efficient with PMTiles than with zxy endpoints.

It could be interesting for offline apps to create a mechanism that downloads tiles from a PMTiles archive and stores them in the existing offline cache...

Describe alternatives you've considered
The current offline download mechanism is a viable existing alternative.

Additional context
Measurements of @bdon have shown that pmtiles extract... can be extremely fast...

@wipfli wipfli added the enhancement New feature or request label May 1, 2024
@louwers
Copy link
Collaborator

louwers commented May 1, 2024

This is an interesting idea. Offline downloads of large areas are indeed horribly slow currently.

Though there would be some complexities involved in converting from PMTiles to MBTiles for storage.

@acalcutt
Copy link
Collaborator

acalcutt commented May 1, 2024

That mapgl-tile-renderer tool could probably be used for small area exports. it exports mbtiles but I added pmtiles source support to it . you don't really need the rendering aspect, but if you are supplying a style with rasters the effect is pretty much the same.

Does maplibre have a tool now to download images for offline use now?

@bdon
Copy link

bdon commented May 2, 2024

Can this be accomplished outside of the maplibre native codebase, and then just deliver the tile archive in a format MLN understands?

@louwers
Copy link
Collaborator

louwers commented May 2, 2024

@bdon Yes you can merge in a database that exists on the local filesystem.

expected<OfflineRegions, std::exception_ptr> mergeDatabase(const std::string& sideDatabasePath);

@louwers
Copy link
Collaborator

louwers commented Nov 14, 2024

During today's TSC meeting @JesseCrocker mentioned that he had to implement his own offline database due to the limitations of the built-in one. This idea from @wipfli was also discussed.

I'll write some documentation about the current offline database implementation so we can get the ball rolling. Downloading an area, parsing it and writing it out to a SQLite database in the correct format should not be too complicated. I think it makes sense to re-use the current offline database, since despite its flaws it is widely in use. #3017

@louwers louwers removed the enhancement New feature or request label Nov 26, 2024
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

No branches or pull requests

4 participants