mapbox / mbutil

Importer and Exporter of MBTiles
http://mapbox.com/developers/
BSD 3-Clause "New" or "Revised" License
762 stars 199 forks source link

Disk to MBTiles - which schema to use? #67

Closed grovduck closed 7 years ago

grovduck commented 8 years ago

I know I'm likely beating a dead horse, but I'm still a bit confused about converting disk tiles to MBTiles when my disk tiles are stored as XYZ. In my case, I'm generating pixel level UTFGrid tiles through some custom code and exporting them to disk in XYZ schema. When I go to convert these disk tiles to MBTiles and use this syntax:

mb-util --scheme=xyz disk_dir foo.mbtiles

the tiles are stored in the mbtiles file as TMS due to these lines. But if I use --scheme=tms the Y flip is avoided and the tiles get stored as XYZ in mbtiles.

In looking through mapbox.js 2.2.3, I'm not seeing where the scheme of Grid layers is being read in (ie. specifying scheme: tms or scheme: xyz has no effect) and if the tiles are not stored in XYZ they don't display correctly. I may be completely off base - but wondering if something has changed between #33 and now.

e-n-f commented 8 years ago

As far as I know everything always expects to find tiles stored in the file as TMS, with the Y axis flipped from the usual XYZ scheme.

grovduck commented 8 years ago

@ericfischer - I'm seeing some UTFGrid tiles with XYZ in their tilejson (e.g. http://a.tiles.mapbox.com/v4/examples.map-8ced9urs.json). From what I can tell, TMS tiles are correctly handled on L.mapbox.tileLayer, but not on L.mapbox.gridLayer. I'm sure I'm wrong, but I can't figure it out.

e-n-f commented 8 years ago

Wow, I had no idea that there was any client-side handling of TMS and thought that tiles were always TMS in mbtiles and XYZ when served individually.

It looks like it would probably be a pretty small change to grid_layer.js to add the tms check and flip the Y axis when necessary, so I guess this should be considered a bug in mapbox.js rather than in mbutil?

grovduck commented 8 years ago

This is embarrassing. I actually had posted on mapbox.js over a year ago (mapbox/mapbox.js#882) and @tmcw recommended writing out xyz from mb-tiles. So I guess the gotcha here is folks expecting scheme=xyz to work for UTFGrid MBTiles. Maybe just a warning here would be sufficient.

sgillies commented 7 years ago

Closing for lack of clear next action.