Skip to content

Commit feb298d

Browse files
Emanuelmsjvpre-commit-ci[bot]CommanderStorm
authored
docs: add binary diff documentation for mbtiles (#2583)
This closes #1383 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
1 parent 6b33822 commit feb298d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/content/mbtiles-diff.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,45 @@ sqlite3 src_file.mbtiles \
7474
"INSERT OR REPLACE INTO tiles (zoom_level, tile_column, tile_row, tile_data) "\
7575
" SELECT * FROM diffDb.tiles WHERE tile_data NOTNULL;"
7676
```
77+
78+
## Binary Diff Support
79+
80+
The `mbtiles diff` command supports binary patching via the `--patch-type` flag,
81+
which can significantly reduce the size of difference files.
82+
83+
The flag combines two choices:
84+
85+
- **Input type** - whether the tiles are raw or gzip-compressed
86+
- **Output type** - whether to store whole tiles (`whole`) or binary diffs (`bin-diff`)
87+
88+
The key distinction is between `whole` and `bin-diff`:
89+
90+
| `--patch-type` | Input | Output |
91+
| --------------- | ------------ | -------------------------------- |
92+
| `whole` | any | Full tile stored as-is |
93+
| `bin-diff-raw` | uncompressed | Brotli-compressed binary diff |
94+
| `bin-diff-gz` | gzip | Binary diff of decompressed data |
95+
96+
### Creating a diff
97+
98+
```bash
99+
mbtiles diff original.mbtiles updated.mbtiles diff.mbtiles --patch-type bin-diff-raw
100+
```
101+
102+
### Applying a patch
103+
104+
The `mbtiles` CLI automatically detects and applies binary patches
105+
if `bsdiffraw` or `bsdiffrawgz` tables are present:
106+
107+
```bash
108+
mbtiles copy diff.mbtiles original.mbtiles target.mbtiles --apply-patch
109+
```
110+
111+
!!! note
112+
`bin-diff-gz` skips `agg_tiles_hash_after_apply` validation after
113+
patching, because re-compressing gzip tiles may produce different bytes.
114+
Use `bin-diff-raw` if you need aggregate hash validation.
115+
116+
!!! note
117+
`mbtiles apply-patch` does not currently support binary patching.
118+
Use `mbtiles copy --apply-patch` instead.

0 commit comments

Comments
 (0)