S2TilesWriter

Struct S2TilesWriter 

Source
pub struct S2TilesWriter<W: Writer> { /* private fields */ }
Expand description

§S2 Tiles Writer

§Description

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

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

§Usage

This struct uses the TileWriter trait.

Takes a Writer input to write data to.

The methods you have access to:

use gistools::{
    parsers::{BufferWriter, Writer},
    util::CompressionFormat,
    writers::{S2TilesWriter, TileWriter},
};
use s2_tilejson::Metadata;

let local_writer = BufferWriter::default();
let mut s2tiles_writer = S2TilesWriter::new(local_writer, 9, CompressionFormat::None);

let s = String::from("hello world");
let buf = s.as_bytes().to_vec();

// write data in an wm tile
s2tiles_writer.write_tile_wm(0, 0, 0, buf.clone());
// or write data in an s2 tile
s2tiles_writer.write_tile_s2(0.into(), 0, 0, 0, buf.clone());

// finish
s2tiles_writer.commit(Metadata::default(), None);
  • https://github.com/Open-S2/s2tiles/blob/master/s2tiles-spec/1.0.0/README.md

Implementations§

Source§

impl<W: Writer> S2TilesWriter<W>

Source

pub fn new(writer: W, maxzoom: u8, compression: CompressionFormat) -> Self

given a compression scheme, maxzoom, and a data writer, create an instance to start storing tiles and metadata. Compression describes how both the tiles and the metadata are compressed

Source

pub fn writer(&mut self) -> &mut W

Borrow the writer

Source

pub fn put_tile_fzxy( &mut self, face: Face, zoom: u8, x: u32, y: u32, data: Vec<u8>, )

Write a tile to the S2Tiles file given its (face, zoom, x, y) coordinates.

§Parameters
  • face: the Open S2 projection face
  • zoom: the zoom level
  • x: the tile X coordinate
  • y: the tile Y coordinate
  • data: the tile data to store
Source

pub fn put_tile(&mut self, id: S2CellId, data: Vec<u8>)

Inserts a tile into the S2Tiles store.

§Parameters
  • id: the tile ID
  • data: the tile data

Trait Implementations§

Source§

impl<W: Debug + Writer> Debug for S2TilesWriter<W>

Source§

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

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

impl<W: Writer> TileWriter for S2TilesWriter<W>

Source§

fn commit( &mut self, metadata: Metadata, tile_compression: Option<CompressionFormat>, )

Finish writing by building the header with root and leaf directories

Source§

fn write_tile_wm(&mut self, zoom: u8, x: u32, y: u32, data: Vec<u8>)

Write a Web Mercator tile to the folder location given its (zoom, x, y) coordinates.
Source§

fn write_tile_s2(&mut self, face: Face, zoom: u8, x: u32, y: u32, data: Vec<u8>)

Write a S2 tile to the folder location given its (face, zoom, x, y) coordinates.

Auto Trait Implementations§

§

impl<W> Freeze for S2TilesWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for S2TilesWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for S2TilesWriter<W>
where W: Send,

§

impl<W> Sync for S2TilesWriter<W>
where W: Sync,

§

impl<W> Unpin for S2TilesWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for S2TilesWriter<W>
where W: 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