Skip to main content

geolith_tiles_builder/raster/
mod.rs

1//! Raster basemap archiver: XYZ/WMTS tile endpoints → `PMTiles`.
2//!
3//! Downloads a tile pyramid from any `{z}`/`{x}`/`{y}` HTTP endpoint with
4//! polite rate limiting and a resumable on-disk cache, then packs the
5//! tiles into a `PMTiles` v3 archive with content deduplication. Supports
6//! hybrid pyramids (planet low zooms + one deep-zoom region) for
7//! basemap-drape demos.
8
9pub mod archive;
10pub mod cache;
11pub mod fetch;
12pub mod pyramid;
13pub mod template;
14
15pub use archive::{RasterBuildOptions, RasterBuildStats, build_raster_archive};
16pub use fetch::HttpFetcher;
17pub use pyramid::PyramidSpec;
18pub use template::UrlTemplate;
19
20/// Build a raster basemap archive from the tiles `options` describe and write
21/// it to `output`.
22///
23/// # Errors
24///
25/// Propagates download failures that survive retry and archive write errors.
26pub fn run(options: &RasterBuildOptions, output: &std::path::Path) -> anyhow::Result<()> {
27    let total = options.pyramid.count();
28    tracing::info!(
29        tiles = total,
30        min_zoom = options.pyramid.min_zoom,
31        max_zoom = options.pyramid.max_zoom,
32        concurrency = options.concurrency,
33        cache = %options.cache_dir.display(),
34        "raster archive build starting"
35    );
36
37    let fetcher = HttpFetcher::new();
38    let stats = build_raster_archive(&fetcher, options, output)?;
39    tracing::info!(
40        output = %output.display(),
41        downloaded = stats.downloaded,
42        cached = stats.cached,
43        missing = stats.missing,
44        tiles = stats.tiles_written,
45        unique = stats.unique_tiles,
46        "raster archive written"
47    );
48    Ok(())
49}