-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
[FEATURE] PMTiles output format #98
Comments
I think this makes sense, probably migrate the |
Would it make sense to structure this as a separate Java library? If so, can that live alongside the python/js implementations at https://github.com/protomaps/PMTiles or should it live in its own Git repository? |
@bdon a separate library would be nice, then the wrapper in planetiler would be pretty minimal. At the simplest it would need an API like:
For performance optimizations it might make sense to expose the hashing function and an API to write a tile with a known hash as well so the writer could avoid hashing the same bytes over and over again, but we could just start with something simple and add that after profiling if necessary. |
Also @bdon could you elaborate on the tile ordering optimization? Is the main reason to put nearby tiles into the same index leaves? Planetiler packs tile x/y/z coordinates into a 32 bit integer that defines the order in which tiles are emitted, so I'd have to express a different ordering strategy as a different mapping from x/y/z to int. |
The tile ordering refers to the order of the tiles in the archive; as of spec v2 their entries in the index is strictly defined (ascending z/x/y). If tiles are in Hilbert order in the archive, they are guaranteed to be nearby in the file if they're nearby in 2D - this locality makes a big latency difference if you're serving from disk and the OS is paging, but usually doesn't make a difference for cloud storage (depends on how it's implemented). |
I also found that writing pmtiles output is substantially faster (3 minutes for the planet), so I'm going to include a first pass of this in my "reducing single-threaded bottlenecks" workstream. I'll write a pmtiles class with the goal of eventually extracting it to https://github.com/protomaps/PMTiles. |
@bdon would it be possible to use the go-pmtiles implementation here in Java in Planetiler? |
I run Planetiler on the Shortbread configurable schema on the full planet. It created something like a 68 GB output file. Then I converted the .mbtiles to .pmtiles (25 minutes) and now I am uploading the file to R2 (roughly 30 minutes). What would be amazing is if Planetiler could directly produce PMTiles and stream them to a S3-compatible storage provider... |
The plan is to output the PMTiles v3 format directly in the java code. It's on my plate, but need to finish up the Tippecanoe output first :) |
* add package com.onthegomap.planetiler.writer * create new interface TileArchive * rename MbtilesMetadata to TileArchiveMetdata, make MbtilesWriter into general TileArchiveWriter
* add package com.onthegomap.planetiler.writer * create new interface TileArchive * rename MbtilesMetadata to TileArchiveMetdata, make MbtilesWriter into general TileArchiveWriter
* add package com.onthegomap.planetiler.writer * create new interface TileArchive * rename MbtilesMetadata to TileArchiveMetdata, make MbtilesWriter into general TileArchiveWriter
* add package com.onthegomap.planetiler.writer * create new interface TileArchive * rename MbtilesMetadata to TileArchiveMetdata, make MbtilesWriter into general TileArchiveWriter
This is cool to see. What is the status? Almost done? |
Getting closer. #502 wraps up most of the internal bits but we will need to also expose this output format to configurations/command line for the next point release. |
I am really looking forward to #502. Is it possible with Just to share my numbers: My custom planet mbtiles file is 45 GB and it takes 15 minutes to write for planetiler. Then it takes 18 minutes to convert the file from |
The pmtiles writer is going to write the whole file sequentially, then when it finishes it will go back to the beginning and write the header and root directory. I'm not sure if that pattern would work integrating with a third-party upload tool? Theoretically I think planetiler could do the upload directly using the S3 multi-part upload API - it would just write the first part last once it knows what the first header/root directory will look like. At the very least, #502 should combine your first 2 steps into one step that takes less than 15 minutes. |
It should be simple to run planetiler and rclone in sequence to perform the upload. My thought for the next v4 spec of pmtiles (backwards compatible, don't worry) is to allow for the header and root directories to be at the end of the archive. This would make the entire format streamable, meaning planetiler could write to storage as it's assembling the tiles, saving time and local disk space. To make this work however, we need to validate that every storage platform pmtiles v3 runs on supports end-addressing HTTP range requests correctly. However, what @msbarry said about multipart uploads out-of-order would be even better and not require a spec revision. I'm not sure if that multipart behavior is consistent across storage platforms though. |
Resolved by #502 |
Thanks a lot for this. Can we use the command line to generate PMTILES ? |
Almost... I'm working on a change now so you can say |
I did a comparison between the direct pmtiles writer in planetiler and the mbtiles writer + conversion afterwards to pmtiles. I did a planet run with my custom map tileset https://github.com/wipfli/swiss-map. Here is the result:
This is on a 12 core, 128 GB machine. The logs are available here: https://gist.github.com/wipfli/17bb8ad8d123f7d93313417dc7d4fac5 It is surprising that the new pmtiles writer does not outperform the old way significantly. Did I somehow mess up some settings? |
Archive writing is the only part that gets faster with pmtiles. Here's what I see for pmtiles:
and for mbtiles:
the archive time is dominated by |
Nice thanks! |
I had a bug in my script: I created I then checked how long So the result in my custom planet tile set is:
So the new method is almost 13 percent faster! |
Hi,one question: sudo java -Xmx1g -jar planetiler.jar --download --area=monaco --output=monaco.pmtiles However,no monaco.pmtiles file is being created inside data folder,only an output.mbtiles file. What am I missing? Thanks |
It creates output.pmtiles in the current folder, no? |
Oh you're probably using the latest release jar and I haven't made a release for a while. I should do a release and get that up to date! |
Hi, |
@etiennejourdier what docker command are you running exactly? |
I used the one in the readme for smaller extracts plus the output option
|
I think you need --output=/data/output.pmtiles to get it into the mapped volume |
Of course it seems obvious now that I'm reading it! Thanks! |
Is your feature request related to a problem? Please describe.
Currently, Planetiler outputs mbtiles which requires a tileserver, i.e., static file hosting like on github pages is not enough to serve tiles.
Describe the solution you'd like
PMTiles can be used to serve vector tiles with range requests and they don't require a tile server. Planetiler could implement a pmtiles writer.
Describe alternatives you've considered
@bdon created a mbtiles to pmtiles converter:
Additional context
the powerlines example uses pmtiles https://github.com/wipfli/powerlines-switzerland
The text was updated successfully, but these errors were encountered: