The repository currently sets publish = false, so another local project uses
a path dependency while developing. Create the application next to the clone,
then replace the relative path if your directories differ:
# Starting inside the async-geotiff-rs checkout:cd ..
cargo new async-geotiff-demo
cd async-geotiff-demo
To avoid the system libproj dependency while retaining the mosaic APIs used
by the example server, set default-features = false, features = ["mosaic"] on
the path dependency. General CRS transformations will then be unavailable.
Render one tile
usestd::sync::Arc;useasync_geotiff::io::cog::CogReader;useasync_geotiff::style::TileStyle;useasync_geotiff::tiler::Tiler;useasync_geotiff::tms::{TileCoord,TileMatrixSet};#[tokio::main]asyncfnmain()-> Result<(),Box<dynstd::error::Error>>{leturl="https://raw.githubusercontent.com/cogeotiff/rio-tiler/0b08b7f35a8b639cee2f35a0cb565034f7b55bfd/tests/fixtures/cog.tif";letreader=Arc::new(CogReader::builder().source_id(url).open_http(url).await?,);lettiler=Tiler::new(reader);letstyle=TileStyle::from_query("colormap_name=viridis&rescale=0,3000")?;letcoord=TileCoord{tms: TileMatrixSet::WebMercatorQuad,z: 0,x: 0,y: 0,};ifletSome(bytes)=tiler.tile(coord,&style).await?{std::fs::write("tile.png",bytes)?;}else{eprintln!("tile is outside the dataset or projection domain");}Ok(())}
TileStyle::from_query accepts the same query string used by the example HTTP
server, without the leading ?. Save the example as src/main.rs, then run
cargo run. The pinned URL is a small, range-capable test COG; replace it
after verifying the integration.
Share memory and CPU budgets
For multiple COGs, create one block cache and give every reader a stable,
distinct source ID: