Skip to main content

oxigeo_pmtiles/
lib.rs

1//! Pure Rust PMTiles v3 reader and writer.
2//!
3//! Parses the 127-byte fixed header ([`header`]), varint-encoded directory
4//! entries ([`directory`]), and provides a high-level reader ([`pmtiles`])
5//! and writer ([`writer`]).  Tile IDs are computed via the Hilbert curve
6//! ([`hilbert`]).  Structured JSON metadata access is provided via
7//! [`metadata`].  Archive compaction (gap removal) is available via
8//! [`compact`].  Sub-region extraction is available via [`extract`].
9//! Re-compression between gzip / brotli / zstd is available via the
10//! `transcode` module (feature-gated behind `compression`).  Tile-set
11//! diffing between two archives is available via [`diff`].
12
13pub mod compact;
14pub mod diff;
15pub mod directory;
16pub mod error;
17#[cfg(feature = "http-range")]
18pub mod etag_cache;
19pub mod extract;
20pub mod header;
21pub mod header_v2;
22pub mod hilbert;
23#[cfg(feature = "http-range")]
24pub mod http_reader;
25pub mod layout;
26pub mod metadata;
27pub mod pmtiles;
28pub mod tile_detect;
29#[cfg(feature = "compression")]
30pub mod transcode;
31pub mod v2_reader;
32pub mod validate;
33pub mod varint;
34pub mod webmerc;
35pub mod writer;
36
37#[cfg(feature = "async")]
38pub mod async_reader;
39
40#[cfg(feature = "cloud-storage")]
41pub mod cloud_reader;
42
43#[cfg(feature = "mbtiles")]
44pub mod mbtiles_export;
45
46#[cfg(feature = "http-range")]
47pub use etag_cache::EtagCache;
48#[cfg(feature = "http-range")]
49pub use http_reader::HttpPmTilesReader;
50
51pub use compact::{
52    CompactOptions, CompactStats, compact_archive, compact_archive_default,
53    compact_archive_with_stats,
54};
55pub use diff::{DiffReport, DiffSummary, TileChange, diff_archives, diff_archives_summary};
56pub use directory::{DirectoryEntry, decode_directory, decode_varint};
57pub use error::PmTilesError;
58pub use extract::{ExtractOptions, bbox_to_tile_range, extract_subregion};
59pub use header::{Compression, PmTilesHeader, TileType};
60pub use hilbert::{hilbert_to_xy, tile_id_to_zxy, xy_to_hilbert, zxy_to_tile_id};
61pub use layout::{LayoutAnalysis, LayoutStrategy, analyze_tile_ordering, choose_strategy};
62pub use metadata::PmTilesMetadata;
63pub use pmtiles::{PmTilesReader, TileInfo};
64pub use tile_detect::{DetectedTileFormat, detect_tile_format};
65#[cfg(feature = "compression")]
66pub use transcode::{
67    TranscodeOptions, TranscodeStats, transcode_archive, transcode_archive_with_stats,
68    transcode_tile,
69};
70pub use validate::{ValidationIssue, ValidationReport, validate_archive, validate_archive_strict};
71pub use varint::encode_varint;
72pub use webmerc::{lonlat_to_tile, tile_bounds_lonlat, tile_to_lonlat};
73pub use writer::PmTilesBuilder;
74
75#[cfg(feature = "async")]
76pub use async_reader::AsyncPmTilesReader;
77
78#[cfg(feature = "cloud-storage")]
79pub use cloud_reader::{CloudCredentials, CloudObjectUri, CloudPmTilesReader, CloudProvider};
80
81#[cfg(feature = "mbtiles")]
82pub use mbtiles_export::{MbTilesConn, MbTilesExportStats, MbTilesExporter};
83
84pub use header_v2::{
85    PMTILES_V2_MAGIC, PmTilesV2Entry, PmTilesV2Header, parse_v2_header, read_v2_entry,
86    zxy_to_v2_tile_id,
87};
88pub use v2_reader::{PmTilesV2Reader, V2Tile, detect_pmtiles_version};
89
90#[cfg(feature = "parallel")]
91pub mod parallel_encode;
92#[cfg(all(feature = "parallel", feature = "compression"))]
93pub use parallel_encode::compress_tile;
94#[cfg(feature = "parallel")]
95pub use parallel_encode::{ParallelBuildStats, ParallelEncodeConfig, RawTile};
96#[cfg(feature = "parallel")]
97pub use parallel_encode::{build_pmtiles_parallel, compress_tiles_parallel};