Arsir Peta

ENID

Notes · · 1 min read

Inside an MBTiles file

An offline pack is often just an SQLite database with one table of tiles and one of facts about them.

MBTiles stores a tile set in an SQLite database, a single file that any device can open. The specification asks for two things. A tiles table, or a view that looks like one, with four columns: zoom level, tile column, tile row and the tile's data. And a metadata table of name and value pairs: the pack's name, its format, its bounds and centre, its zoom range and its attribution.

One detail catches people out: MBTiles numbers rows from the bottom, the older Tile Map Service way, while most map apps ask for rows counted from the top. The conversion is in where a tile lives, and getting it wrong shows every tile in the wrong row.

Many tools store each distinct tile image once and point to it from a map table, behind a tiles view, so a pack with large areas of sea or forest is much smaller than its tile count suggests.

Because it is a database, a pack can be updated in place. We do not, on devices: a pack is replaced as a whole, so a crew never holds a half updated map. For packs that are read over the network instead, see one file instead of a tile server.