Mosaics and STAC
The default-enabled mosaic Cargo feature adds MosaicTiler and the
MosaicSource trait; applications that do not need mosaics can disable default
features. Because that also disables proj, use
--no-default-features --features proj when general CRS transformation is
still required. The source maps a tile coordinate to assets; the tiler opens
and warps those assets, reduces overlapping pixels, and renders the composite
once.
MosaicJSON
Run the embedded example or pass a MosaicJSON file:
The parser accepts MosaicJSON 0.0.3. Its quadkey index is defined in
WebMercatorQuad; using a MosaicJSON source with WorldCRS84Quad returns a
query error.
Connect the example server to a file at startup:
Tiles are then available under /mosaic/tiles/....
Pixel selection
| Strategy | Behavior |
|---|---|
First | First valid pixel wins; stops early after the tile is fully covered. |
Highest | Maximum value in the first output band per pixel across every asset. |
Lowest | Minimum value in the first output band per pixel across every asset. |
Mean | Streaming mean of valid samples; constant memory in asset count. |
Median | Median of valid samples; retains every contributing image until completion. |
“First output band” is internal index 0; user-facing bidx values remain
1-indexed.
MosaicConfig defaults to 8 assets processed concurrently per chunk, an
opened-reader capacity of 256 in each MosaicTiler reader pool, and a hard cap
of 64 assets per requested tile. When the cap is exceeded, the tiler logs a
warning and keeps the first assets in source-provided order. Configure all
three limits through the builder:
Keep the asset cap enabled for untrusted or low-zoom indexes to prevent fetch amplification. Choose a deterministic source order when truncation would affect visual correctness.
STAC demo
Enable stac and provide all three startup settings:
The API, collection, and asset key are fixed at process startup. HTTP query parameters cannot turn the demo into an arbitrary STAC or COG proxy.
After startup, open http://127.0.0.1:8080/maplibre. When STAC is configured, the MapLibre viewer selects mosaic mode by default and lets you verify the configured collection without guessing a tile coordinate.
HTTP asset policy
The default policy allows public and private HTTP(S) assets but blocks
loopback, link-local, and cloud-metadata destinations. Use
HttpAccessPolicy::strict() for fully untrusted documents: it requires HTTPS
and also blocks private address ranges. permissive() should be reserved for
operator-controlled asset lists.
The example server uses the default policy and does not expose an environment
override. A service that accepts untrusted mosaic or STAC documents should
construct MosaicTiler itself and pass strict() through the builder as shown
above.
Presigned query strings are redacted from mosaic errors and log messages. The access policy is a URL-resolution guard, not a complete outbound proxy sandbox. Applications still own client timeouts, redirect policy, egress firewalling, document-size limits, and any logging they add around the library.