oscarfonts / mapbox-gl-cordova-offline

Offline vector maps in Cordova using Mapbox GL JS
Other
60 stars 36 forks source link

Fix loading tiles that are not compressed #46

Open jpilet opened 5 years ago

michogar commented 5 years ago

Hi, @jpilet thanks for the PR, in which cases have you found the tiles are uncompressed?

jpilet commented 5 years ago

I think some small ocean tiles are smaller uncompressed than compressed. I used tilelive copy to assemble multiple mbtiles files and I got exceptions in tile decoding. In "tileinfo" code, uncompression is done optionally: first by checking the headers, then by decompressing only if required. See https://github.com/mapbox/mapnik-vector-tile/blob/master/examples/c%2B%2B/tileinfo.cpp#L64 and https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_compression.hpp#L18.

So the proper way of doing here would be the same: first check the header, then call inflate only if needed. I was short on time so I simply caught the exception thrown by inflate.