Skip to content

Commit

Permalink
Add links to schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Oct 31, 2023
1 parent 2e20b0a commit 6084977
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/51-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ sqlite3 src_file.mbtiles \
```

### validate
If the `.mbtiles` file is of `flat_with_hash` or `normalized` type, then verify that the data stored in columns `tile_hash` and `tile_id` respectively are MD5 hashes of the `tile_data` column.
If the `.mbtiles` file is of [flat_with_hash](52-schemas.md#flat-with-hash) or [normalized](52-schemas.md#normalized) type, then verify that the data stored in columns `tile_hash` and `tile_id` respectively are MD5 hashes of the `tile_data` column.
```shell
mbtiles validate src_file.mbtiles
```

## Content Validation
The original [MBTiles specification](https://github.com/mapbox/mbtiles-spec#readme) does not provide any guarantees for the content of the tile data in MBTiles. This tool adds a few additional conventions to ensure that the content of the tile data is valid.

A typical Normalized schema generated by tools like [tilelive-copy](https://github.com/mapbox/TileLive#bintilelive-copy) use MD5 hash in the `tile_id` column. The Martin's `mbtiles` tool can use this hash to verify the content of each tile. We also define a new `flat-with-hash` schema that stores the hash and tile data in the same table. This schema is more efficient than the `normalized` schema when data has no duplicate tiles (see below). Per tile validation is not available for `flat` schema.
A typical Normalized schema generated by tools like [tilelive-copy](https://github.com/mapbox/TileLive#bintilelive-copy) use MD5 hash in the `tile_id` column. The Martin's `mbtiles` tool can use this hash to verify the content of each tile. We also define a new [flat-with-hash](52-schemas.md#flat-with-hash) schema that stores the hash and tile data in the same table. This schema is more efficient than the [normalized](52-schemas.md#normalized) schema when data has no duplicate tiles (see below). Per tile validation is not available for `flat` schema.

Per-tile validation will catch individual invalid tiles, but it will not detect overall datastore corruption (e.g. missing tiles or tiles that shouldn't exist, or tiles with incorrect z/x/y values).
For that, Martin `mbtiles` tool defines a new metadata value called `agg_tiles_hash`. The value is computed by hashing `cast(zoom_level AS text), cast(tile_column AS text), cast(tile_row AS text), tile_data` combined for all rows in the `tiles` table/view, ordered by z,x,y.
Expand Down

0 comments on commit 6084977

Please sign in to comment.