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

Unusable pmtiles file generated if source mbtiles file has no metadata #60

Closed
russss opened this issue Aug 25, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@russss
Copy link

russss commented Aug 25, 2023

I think if you use the pmtiles command line tool to convert an mbtiles into a pmtiles file, and the mbtiles doesn't have bounds/center metadata, then you get a successfully-generated pmtiles file which the JS library (at least) will silently ignore.

I'm 80% sure this is what's happening, but I don't have the time to dig into the code to confirm at the moment (sorry).

@bdon
Copy link
Member

bdon commented Aug 26, 2023

Can you share the mbtiles file?

Is it possible that the center/bounds are defaulting to the world and it just not visible at the scale when loaded in JS?

@russss
Copy link
Author

russss commented Aug 28, 2023

I dug into this a bit more, hopefully this explains it better:

  1. I created an .mbtiles file from a bunch of pbf files using mb-util. There was no metadata file included, so the metadata table in the resulting mbtiles database was empty.
  2. I created a .pmtiles file from this .mbtiles file, which results in the pmtiles file having a value of 0 for all the bounds. (Full pmtiles show output included below.)
  3. I try to display this pmtiles file in maplibre-js. MapLibre won't try and fetch tiles if they're outside the source's bounding box, and the pmtiles provider uses the bounds from the header of the pmtiles file, so the bounding box is [0,0,0,0], which results in the pmtiles file being silently ignored.

I'd suggest that the pmtiles command should refuse to create files with an invalid bounding box such as this, or at least issue a warning. I'd also suggest that the JS library should probably issue a warning if the pmtiles file has an invalid bounding box.

Result of `pmtiles show`
$ pmtiles show ./buildmap-nometadata.pmtiles
pmtiles spec version: 3
total size: 24 MB
tile type: Unknown
bounds: 0.000000,0.000000 0.000000,0.000000
min zoom: 7
max zoom: 20
center: 0.000000,0.000000
center zoom: 7
addressed tiles count: 12946
tile entries count: 8418
tile contents count: 5367
clustered: true
internal compression: 2
tile compression: 0

@bdon
Copy link
Member

bdon commented Aug 28, 2023

We can either

  1. error out when the bounds is invalid - has an area or 0, or the min is greater than max, out of the coordinate system, etc
  2. detect the error cases but default the bounds to -180,-90,180,90.

I have a slight preference for 2 because the MBTiles spec uses the SHOULD language (a valid bounds is not a hard requirement)

@bdon bdon added the bug Something isn't working label Sep 11, 2023
bdon added a commit that referenced this issue Sep 12, 2023
…60]

* error out if bounds is degenerate (zero or less area)
@bdon
Copy link
Member

bdon commented Sep 12, 2023

opened a PR: #77

  • If the bounds is missing from MBTiles, default it to the web mercator world -180,-90,180,90.
  • If the bounds is zero area or less, raise an error. This should catch the case you have before, in which case you need to provide corrected information in the MBTiles before converting.

bdon added a commit that referenced this issue Sep 13, 2023
] (#77)

* mbtiles convert: default bounds to world if bounds metadata missing. [#60]

* error out if bounds is degenerate (zero or less area)

* convert: don't crash on empty mbtiles [#41]
@bdon
Copy link
Member

bdon commented Sep 21, 2023

@russss this should be resolved by https://github.com/protomaps/go-pmtiles/releases/tag/v1.10.0 which will fail if a zero-area bounds is passed, but accept no bounds. Please re-open if this is still an issue!

@bdon bdon closed this as completed Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants