Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

Reference

Exact routes, parameters, features, defaults, and operational settings.

Use this section when you need exact supported values and defaults.

1 - Example HTTP API

Routes, tile path format, style parameters, and response behavior.

The HTTP API belongs to examples/serve.rs; it is not part of the library’s dependency surface.

Routes

Method and pathPurpose
GET /tiles/{tms}/{z}/{x}/{y}.{ext}Render a tile from the selected single COG.
GET /mosaic/tiles/{tms}/{z}/{x}/{y}.{ext}Render a tile from the configured mosaic or STAC source.
GET /datasetsList local TIFF files discovered under data/.
GET /cache/statsReturn decoded-block cache statistics.
GET /formatsReturn output formats compiled into the server.
GET /boundsReturn bounds used by the example viewers.
GET, HEAD /data/{name}Serve a discovered local TIFF with range support.

Supported TMS names are WebMercatorQuad and WorldCRS84Quad. Supported extensions are png, feature-gated webp, and feature-gated jpg/jpeg.

Style parameters

ParameterRepeatDefault or exampleMeaning
bidxyesbidx=1&bidx=2&bidx=31-indexed source-band selection.
expressionno(b5-b4)/(b5+b4)Arithmetic expression producing one derived band.
rescaleyes0,3000Explicit per-band min,max range; highest stretch priority.
stretchnominmax, percent, stddevAutomatic stretch mode.
pcno2,98Percentile cut used by stretch=percent.
sigmano2.0Standard-deviation multiplier.
nodatanonan, inf, -inf, or floatOverride the dataset nodata value.
colormap_namenoviridisBuilt-in single-band color ramp.
color_formulanogamma RGB 1.5Supported rio-color operation sequence.
resamplingnonearestSource read or resize kernel.
reprojectnonearestWarp-time resampling kernel.
tilesizeno256One of 64, 128, 256, 512, or 1024.
formatnopngOptional format assertion; must agree with the path extension.

Resampling kernels are nearest, bilinear, cubic, cubic_spline, lanczos, and average. Average computes a box mean for downsampling and uses nearest behavior when upsampling.

The mosaic tile route additionally accepts pixel_selection=first, highest, lowest, mean, or median. The default is first.

Responses

  • 200 OK returns encoded image bytes.
  • 204 No Content means the coordinate is valid but fully outside the source dataset or projection domain.
  • Invalid style values and malformed coordinates return a client error with a structured library error behind it.

The default output size is 256×256, chosen for broad XYZ-client compatibility.

2 - Cargo features

Compile-time capabilities and their dependency effects.
FeatureDefaultEffect
projyesEnables general CRS transformation through system libproj.
mosaicyesEnables MosaicTiler, MosaicSource, MosaicJSON, and async asset fan-out.
webpnoEnables lossless WebP encoding through image.
jpegnoEnables JPEG encoding; alpha is flattened because JPEG has no alpha channel.
stacnoAdds the STAC client and implies mosaic.
perf-tracingnoEmits detailed internal timing events.
tokio-consolenoEnables Tokio Console integration and implies perf-tracing.

Examples:

# Default: projection + mosaics + PNG
cargo build --release

# Minimal library without general PROJ or mosaics
cargo build --release --no-default-features

# Example server with all image formats
cargo run --release --example serve --features webp,jpeg

# STAC-backed mosaic demo
cargo run --release --example serve --features stac

# Full verification surface
cargo test --all-features --locked

The serve, mosaic_source, and mosaic_json examples require the mosaic feature. PNG support is always compiled.

3 - Example server configuration

Environment variables accepted by the included Axum server.

These variables configure cargo run --example serve. They are example-server contracts, not global library configuration.

VariableDefaultMeaning
ASYNC_GEOTIFF_BIND127.0.0.1:8080Socket address for the HTTP server.
ASYNC_GEOTIFF_BLOCK_CACHE_MB512Shared decoded-block cache capacity in MiB; must be positive.
ASYNC_GEOTIFF_MAX_DECODE_TASKSavailable parallelismMaximum concurrent decode/stitch CPU jobs; must be positive.
ASYNC_GEOTIFF_MAX_TILE_TASKSavailable parallelismMaximum concurrent tile warp/render CPU jobs; must be positive.
ASYNC_GEOTIFF_PREFETCH_RING1Number of native-block rings prefetched around a read; 0 disables it.
ASYNC_GEOTIFF_SLOW_TILE_MSunsetEmit a slow-tile warning above this positive millisecond threshold.
ASYNC_GEOTIFF_MOSAICunsetPath to a MosaicJSON file loaded at startup.
ASYNC_GEOTIFF_STAC_URLunsetFixed STAC API URL; requires the stac feature and the next two variables.
ASYNC_GEOTIFF_STAC_COLLECTIONunsetFixed STAC collection ID.
ASYNC_GEOTIFF_STAC_ASSET_KEYunsetFixed STAC COG asset key.
ASYNC_GEOTIFF_TOKIO_CONSOLEoffEnable Tokio Console with 1, true, yes, or on when compiled with tokio-console.
RUST_LOGasync_geotiff=debug,warnStandard tracing filter for the example server.

ASYNC_GEOTIFF_MOSAIC and the STAC configuration are mutually exclusive. All three STAC variables must be supplied together.

The decode-task and tile-task values tune single-COG work, but are not a single process-wide CPU cap. The command-line default COG uses separate limiters; lazily selected local datasets share one limiter sized to the larger value; mosaics own their own limiter. The example server does not expose environment variables for MosaicConfig fields such as max_assets_per_tile.

Example

ASYNC_GEOTIFF_BIND=0.0.0.0:8080 \
ASYNC_GEOTIFF_BLOCK_CACHE_MB=1024 \
ASYNC_GEOTIFF_MAX_DECODE_TASKS=8 \
ASYNC_GEOTIFF_MAX_TILE_TASKS=8 \
ASYNC_GEOTIFF_PREFETCH_RING=0 \
ASYNC_GEOTIFF_SLOW_TILE_MS=500 \
RUST_LOG=async_geotiff=info \
  cargo run --release --example serve -- https://example.com/cog.tif

Invalid numeric values fail at process startup instead of being silently clamped.