Skip to main content

PMTilesReader

Struct PMTilesReader 

Source
pub struct PMTilesReader {
    pub data_reader: Arc<DataReader>,
    pub header: HeaderV3,
    pub internal_compression: TileCompression,
    pub leaves_bytes: Arc<Blob>,
    pub leaves_cache: Cache<ByteRange, Arc<EntriesV3>>,
    pub tilejson: TileJSON,
    pub metadata: TileSourceMetadata,
    pub root_bytes_uncompressed: Blob,
    pub root_entries: Arc<EntriesV3>,
}
Expand description

Re‑exports the container registry and common open/write helpers. Reader for PMTiles v3 containers.

Parses the header and directory blobs, merges embedded TileJSON, computes a tile pyramid by traversing directory entries, and exposes tiles via the TileSource interface.

Fields§

§data_reader: Arc<DataReader>

Underlying byte source used to read header, directories, and tile data.

§header: HeaderV3

Parsed PMTiles v3 header with byte ranges, counts, and compression flags.

§internal_compression: TileCompression

Compression algorithm used for internal metadata/directories (e.g., gzip).

§leaves_bytes: Arc<Blob>

Raw (compressed) concatenated blob of all leaf directories.

§leaves_cache: Cache<ByteRange, Arc<EntriesV3>>

Decompression cache mapping leaf directory byte ranges to parsed entries. Concurrent loads of the same range dedup automatically; distinct ranges decompress in parallel.

§tilejson: TileJSON

Merged TileJSON metadata extracted from the PMTiles metadata range.

§metadata: TileSourceMetadata

Runtime parameters (tile format, compression, tile pyramid) advertised by this reader.

§root_bytes_uncompressed: Blob

Uncompressed root directory blob.

§root_entries: Arc<EntriesV3>

Parsed entries of the root directory (shared across queries).

Implementations§

Source§

impl PMTilesReader

Source

pub async fn open(path: &Path, runtime: TilesRuntime) -> Result<PMTilesReader>

Open a PMTiles container from an absolute filesystem path.

Validates and opens a DataReaderFile, then delegates to PMTilesReader::open_data.

§Errors

Returns an error if the file cannot be opened.

Source

pub async fn open_data( data_reader: DataReader, _runtime: TilesRuntime, ) -> Result<PMTilesReader>
where Self: Sized,

Open a PMTiles container from an existing DataReader.

Reads the v3 header, decompresses and parses the metadata (TileJSON) and root directory, prepares leaf directory bytes, computes the tile pyramid, and initializes caches for fast lookups.

§Errors

Returns an error if reading or decompression fails, or if the header/dirs are invalid.

Source

pub fn tile_entries(&self) -> Result<EntriesV3>

Decode and return the root directory entries (EntriesV3).

Trait Implementations§

Source§

impl Debug for PMTilesReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TileSource for PMTilesReader

Source§

fn metadata(&self) -> &TileSourceMetadata

Returns the current reader parameters (tile format, compression, tile pyramid).

Source§

fn tilejson(&self) -> &TileJSON

Returns the parsed and merged TileJSON metadata.

Source§

fn tile<'life0, 'life1, 'async_trait>( &'life0 self, coord: &'life1 TileCoord, ) -> Pin<Box<dyn Future<Output = Result<Option<Tile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a tile by XYZ coordinate.

Converts the coordinate to a Hilbert tile ID, then traverses up to three levels of PMTiles directories to locate the tile. Leaf directories are cached to avoid repeated decompression. Returns Ok(None) if the tile does not exist.

Source§

fn source_type(&self) -> Arc<SourceType>

Returns the source type (container format, processor name, or composite). Read more
Source§

fn tile_pyramid<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Arc<TilePyramid>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the actual tile pyramid for this source.
Source§

fn tile_stream<'life0, 'async_trait>( &'life0 self, bbox: TileBBox, ) -> Pin<Box<dyn Future<Output = Result<TileStream<'static, Tile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously streams all tiles within the given bounding box. Read more
Source§

fn tile_size_stream<'life0, 'async_trait>( &'life0 self, bbox: TileBBox, ) -> Pin<Box<dyn Future<Output = Result<TileStream<'static, u32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Streams the stored byte sizes of all tiles within the given bounding box. Read more
Source§

fn tile_coord_stream<'life0, 'async_trait>( &'life0 self, bbox: TileBBox, ) -> Pin<Box<dyn Future<Output = Result<TileStream<'static, ()>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Streams which tile coordinates exist within the given bounding box. Read more
Source§

fn boxed(self) -> Box<dyn TileSource>
where Self: Sized + 'static,

Converts self into a boxed trait object for dynamic dispatch.
Source§

fn into_shared(self) -> SharedTileSource
where Self: Sized + 'static,

Converts self into a shared reference for concurrent access. Read more
Source§

impl TilesReader for PMTilesReader

Source§

fn open_reader<'async_trait>( reader: DataReader, runtime: TilesRuntime, ) -> Pin<Box<dyn Future<Output = Result<SharedTileSource>> + Send + 'async_trait>>

Opens a tile container from the provided DataReader source. Read more
Source§

fn supports_data_reader() -> bool

Returns true when the reader can open from a generic DataReader source (e.g. for HTTP). File-only readers (MBTiles, TAR) return false.
Source§

fn open_path<'life0, 'async_trait>( path: &'life0 Path, runtime: TilesRuntime, ) -> Pin<Box<dyn Future<Output = Result<SharedTileSource>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Opens a tile container from the file or directory at path. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> TileSourceTraverseExt for T
where T: TileSource + ?Sized,

Source§

fn traverse_all_tiles<'s, 'a, C>( &'s self, traversal_write: &'s Traversal, callback: C, runtime: TilesRuntime, ) -> impl Future<Output = Result<()>> + Send + 'a
where C: FnMut(TileBBox, TileStream<'a, Tile>) -> BoxFuture<'a, Result<()>> + Send + 'a, 's: 'a,

Traverses all tiles according to a traversal plan, invoking a callback for each batch. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool