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(
27    options: &RasterBuildOptions,
28    output: &std::path::Path,
29) -> Result<(), crate::TilesError> {
30    let total = options.pyramid.count();
31    tracing::info!(
32        tiles = total,
33        min_zoom = options.pyramid.min_zoom,
34        max_zoom = options.pyramid.max_zoom,
35        concurrency = options.concurrency,
36        cache = %options.cache_dir.display(),
37        "raster archive build starting"
38    );
39
40    let fetcher = HttpFetcher::new();
41    let stats = build_raster_archive(&fetcher, options, output)?;
42    tracing::info!(
43        output = %output.display(),
44        downloaded = stats.downloaded,
45        cached = stats.cached,
46        missing = stats.missing,
47        tiles = stats.tiles_written,
48        unique = stats.unique_tiles,
49        "raster archive written"
50    );
51    Ok(())
52}