PMTilesReader

Struct PMTilesReader 

Source
pub struct PMTilesReader<R: Reader> { /* private fields */ }
Expand description

§(S2) PMTiles Reader

§Description

A V3.0 PMTiles reader for reading standard WebMercator Tile data and V1.0 S2 Tile data.

A Modified implementation of the PMTiles library. It is backwards compatible but offers support for the S2 Projection.

You can learn more about the S2PMTiles Specification here.

§Usage

PMTilesReader utilizes any struct that implements the Reader trait. Options are crate::parsers::BufferReader, crate::parsers::FileReader, crate::parsers::MMapReader, and crate::parsers::FetchReader.

The methods you have access to:

use gistools::{parsers::FileReader, readers::PMTilesReader};
use std::path::PathBuf;

let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
    .join("tests/readers/pmtiles/fixtures/test_fixture_1.pmtiles");
let file_reader = FileReader::new(path).unwrap();
let mut reader = PMTilesReader::new(file_reader, None);

smol::block_on(async {

// pull out the header
let header = reader.get_header().await;

// get the metadata
let metadata = reader.get_metadata();

// S2 specific functions
let tile = reader.get_tile_s2(0.into(), 0, 0, 0).await;

// WM functions
let tile = reader.get_tile_wm(0, 0, 0).await.unwrap();

});

Implementations§

Source§

impl<R: Reader> PMTilesReader<R>

Source

pub fn new(reader: R, max_size: Option<usize>) -> Self

Given an input path, read in the header and root directory

Source

pub async fn get_header(&mut self) -> S2PMHeader

fetch the s2 metadata as needed

Source

pub fn get_s2_metadata(&mut self, data: &[u8], header: &mut S2PMHeader)

If S2, we need to build the other face’s root directories

Source

pub fn get_metadata(&mut self) -> &Metadata

get the metadata

Source

pub async fn get_tile_s2( &mut self, face: Face, zoom: u8, x: u64, y: u64, ) -> Option<Vec<u8>>

get an S2 tile

Source

pub async fn get_tile_wm(&mut self, zoom: u8, x: u64, y: u64) -> Option<Vec<u8>>

get an WM tile

Source

pub async fn get_tile( &mut self, face: Option<Face>, zoom: u8, x: u64, y: u64, ) -> Option<Vec<u8>>

get a tile, wheather WM or S2

Trait Implementations§

Source§

impl<R: Debug + Reader> Debug for PMTilesReader<R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for PMTilesReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for PMTilesReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for PMTilesReader<R>
where R: Send,

§

impl<R> Sync for PMTilesReader<R>
where R: Sync,

§

impl<R> Unpin for PMTilesReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for PMTilesReader<R>
where R: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V