S2TilesReader

Struct S2TilesReader 

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

§S2 Tiles Reader

§Description

An S2 Tile Reader to store tile and metadata in a cloud optimized format. Similar to PMTiles but simplified to have as few features as possible.

Reads either a Web Mercator tile or an S2 tile to the folder location given its (zoom, x, y) or (face, zoom, x, y) coordinates.

Reads data via the S2Tiles specification.

§Usage

S2TilesReader 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::S2TilesReader};
use std::path::PathBuf;

let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
    .join("tests/writers/fixtures/example.s2tiles");
let file_reader = FileReader::new(path).unwrap();
let mut reader = S2TilesReader::new(file_reader, None);

smol::block_on(async {

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

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

// WM functions
assert!(reader.has_tile_wm(0, 0, 0).await);
let tile = reader.get_tile_wm(0, 0, 0).await;

});
  • https://github.com/Open-S2/s2tiles/blob/master/s2tiles-spec/1.0.0/README.md

Implementations§

Source§

impl<R: Reader> S2TilesReader<R>

Source

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

Create a new S2TilesReader

§Parameters
  • reader - the input reader to parse from
  • max_size - the max size of the cache before dumping old data. Defaults to 20.
Source

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

Get the metadata of the archive

§Returns

The metadata of the archive

Source

pub async fn has_tile_wm(&mut self, zoom: u8, x: u32, y: u32) -> bool

Check if a WM tile exists in the archive

§Parameters
  • zoom: the zoom level of the tile
  • x: the x coordinate of the tile
  • y: the y coordinate of the tile
§Returns

True if the tile exists in the archive

Source

pub async fn has_tile_s2( &mut self, face: Face, zoom: u8, x: u32, y: u32, ) -> bool

Check if an S2 tile exists in the archive

§Parameters
  • face: the Open S2 projection face
  • zoom: the zoom level of the tile
  • x: the x coordinate of the tile
  • y: the y coordinate of the tile
§Returns

True if the tile exists in the archive

Source

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

Get the bytes of the tile at the given (zoom, x, y) coordinates

§Parameters
  • zoom: the zoom level of the tile
  • x: the x coordinate of the tile
  • y: the y coordinate of the tile
§Returns

The bytes of the tile at the given (z, x, y) coordinates, or undefined if the tile does not exist in the archive.

Source

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

Get the bytes of the tile at the given (face, zoom, x, y) coordinates

§Parameters
  • face: the Open S2 projection face
  • zoom: the zoom level of the tile
  • x: the x coordinate of the tile
  • y: the y coordinate of the tile
§Returns

The bytes of the tile at the given (face, zoom, x, y) coordinates, or undefined if the tile does not exist in the archive.

Trait Implementations§

Source§

impl<R: Debug + Reader> Debug for S2TilesReader<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 S2TilesReader<R>
where R: Freeze,

§

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

§

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

§

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

§

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

§

impl<R> UnwindSafe for S2TilesReader<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