Skip to main content

Module directory

Module directory 

Source
Expand description

PMTiles directory builder – root and leaf directory entries.

PMTiles v3 uses a two-level directory: a root directory (<=16_257 bytes compressed, fetched in the initial 16 KiB range request alongside the 127-byte header) and optional leaf directories (stored as data). Each entry maps a tile ID to an offset/length in the data section.

Directories are gzip-compressed (internal_compression = Gzip) per the PMTiles v3 spec. The two-level split algorithm mirrors the go-pmtiles reference: start with max(entries / 3500, 4096) entries per leaf (targeting ~3500 leaves), then increase by 1.2x until the compressed root fits within the caller-supplied byte cap (normally 16_257 = 16_384 - 127 to fit in the consumer’s initial fetch).

See: https://github.com/protomaps/go-pmtiles/blob/main/pmtiles/directory.go

Structs§

DirEntry
A single directory entry mapping a tile range to data.

Functions§

build_directories
Build a PMTiles directory from a list of entries, gzip-compressing the output.
read_varint
Read a varint from a byte slice, returning (value, bytes_consumed).
serialize_directory
Serialize directory entries to the PMTiles v3 varint format.