protomaps / go-pmtiles

Single-file executable tool for working with PMTiles archives
https://docs.protomaps.com/pmtiles/cli
BSD 3-Clause "New" or "Revised" License
361 stars 49 forks source link

allow converting tile types #48

Closed jrhizor closed 1 year ago

jrhizor commented 1 year ago

It'd be great to allow converting between any pair of supported tile types (mvt, png, jpeg, or webp).

Maybe this could be an option for pmtiles convert --format png <a> <b>?

Here's what happened to me (and I imagine other users not super familiar with mapping tools can easily run into similar problems):

  1. I downloaded a small map
  2. I set up hosting following the Cloudflare instructions
  3. Since https://protomaps.com/docs/frontends/leaflet didn't have React-based instructions, I followed a pretty standard Leaflet setup with react-leaflet, pointing a TileLayer at https://<mydomain>/<pmtiles name>/{z}/{x}/{y}.mvt. This resulted in a CORB error due to the fact that TileLayer was creating img objects with mvt files that the Cloudflare server was serving with application/x-protobuf.
  4. I ended up messing around too long with CORS stuff before realizing that the CORB issue was due to the content type.
  5. After more tinkering I figured out how to use the protomaps npm library to create the layer from mvt files.

There are a few options that would make this easier for new users:

  1. Allow converting tile types with the CLI
  2. Allow selecting a specific format when downloading small maps
  3. Add documentation for react-leaflet (I created a separate issue for this)
  4. Add conversion support at the Cloudflare worker level
bdon commented 1 year ago

Thanks for the details. It sounds like the point of confusion is the distinction between vector tiles and raster tiles.

Converting between vector and raster tile data is computationally very expensive and would require bringing in a rasterizer like Maplibre GL native, and is impossible to do in a general style-agnostic way.

bdon commented 1 year ago

Closing this issue as operations on tiles is outside the scope of this utility project, which is only operations on containers.