spatial-monorepo / pmtiles/src / PrefetchOptions
Interface: PrefetchOptions
Defined in: packages/pmtiles/src/prefetchTiles.ts:4
Properties
bounds
bounds: [
number,number,number,number]
Defined in: packages/pmtiles/src/prefetchTiles.ts:6
[west, south, east, north] in degrees
maxBytes?
optionalmaxBytes?:number
Defined in: packages/pmtiles/src/prefetchTiles.ts:28
Max bytes to prefetch. Defaults to 20 MB.
The pmtiles API only exposes a resolved tile's decompressed size, not the raw wire (network) bytes a Range request pulled for it. For archives declaring gzip/brotli tile compression, this budget is accounted conservatively: decompressed byte counts are derated by COMPRESSED_WIRE_BYTES_DERATE (an assumed low-end compression ratio) to approximate real network bytes without ever underestimating them. Uncompressed archives are counted exactly (see issue #959).
When multiple archives are fetched concurrently for the same tile, each archive reserves RESERVED_TILE_BYTES against this budget before it awaits its own fetch, so a sibling archive's synchronous check can't slip past the budget before either one's byte count lands (see issue #1009). The reservation is corrected down to the real byte count afterward, so it only over-counts (never under-counts) while a fetch for a tile this size or smaller is in flight.
maxZoom
maxZoom:
number
Defined in: packages/pmtiles/src/prefetchTiles.ts:8
minZoom
minZoom:
number
Defined in: packages/pmtiles/src/prefetchTiles.ts:7
onError?
optionalonError?: (error,tile) =>void
Defined in: packages/pmtiles/src/prefetchTiles.ts:37
Called whenever an individual tile fetch fails (network error, decode error, aborted request, etc). Prefetching is best-effort and keeps going past individual tile failures — but failures are no longer silently swallowed. Pass this to surface them (e.g. to telemetry, or console.warn during development). If omitted, failures are reported via console.warn so the feature never silently no-ops again (issue #430).
Parameters
error
unknown
tile
archiveUrl
string
x
number
y
number
z
number
Returns
void
