protomaps / go-pmtiles

Single-file executable tool for working with PMTiles archives
BSD 3-Clause "New" or "Revised" License
356 stars 49 forks source link

Adding a --tilejson arg to the show command #110

Closed mikeocool closed 8 months ago

mikeocool commented 8 months ago

And arg to the show command that will output the full tile json -- reusing the code that generates the tilejson from the serve command: pmtiles show --tilejson test.pmtiles

One part of this that's currently lacking is specifying the URL used intiles -- currently it just outputs /{z}/{x}/{y}.mvt. Was thinking either:

bdon commented 8 months ago

I guess I imagined the main use case here is doing something like:

pmtiles show --tilejson foo.pmtiles > foo.json

The TileJSON spec unfortunately requires absolute and not relative URLs for the tiles endpoint. Options I see are:

I think it's ok to have that flag be there and only be relevant for --tilejson, I think it's cleaner than making a whole new subcommand.

Is the context you will use this different from the above?

mikeocool commented 8 months ago

@bdon Yeah, that's pretty much exactly the use case I had in mind.

Went ahead and added a --public-url arg -- that allows you to specify the full url for the tiles -- in case you aren't just hosting the tiles at https://whatever.com/key/{z}/{x}/{y}.mvt -- and added the warning and the placeholder if you don't specify that arg.

So you should now be able to do: pmtiles show --tilejson test.pmtiles or pmtiles show --tilejson --public-url https://example.com/test.pmtiles/{z}/{x}/{y} test.pmtiles

bdon commented 8 months ago

Thanks! I have some small additions I'll add in a followup PR