PMTilesWriter

Struct PMTilesWriter 

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

§(S2) PM Tiles Writer

§Description

A PM or S2PM Tile Writer to store tile and metadata in a cloud optimized format

Implements the TileWriter interface.

Takes a Writer input to write data to.

§Usage

The methods you have access to:

use gistools::{util::CompressionFormat, parsers::BufferWriter, writers::{TileWriter, PMTilesWriter}};
use s2_tilejson::Metadata;
use s2json::Face;

let local_writer = BufferWriter::default();
let mut pmtiles_writer = PMTilesWriter::new(local_writer, CompressionFormat::None);

// setup data
let tmp_str = "hello world";
// write data in tile
pmtiles_writer.write_tile_s2(Face::Face0, 0, 0, 0, tmp_str.as_bytes().to_vec());
pmtiles_writer.write_tile_s2(Face::Face3, 2, 1, 1, tmp_str.as_bytes().to_vec());
// finish (we don't need to specify the compression again)
pmtiles_writer.commit(Metadata::default(), None);

let pmtiles_data = pmtiles_writer.take();

Implementations§

Source§

impl<W: Writer> PMTilesWriter<W>

Source

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

given a compression scheme and a data writer, create an instance to start storing tiles and metadata. Compression will only describle how tiles are stored, nothing more.

Source

pub fn take(&mut self) -> Vec<u8>

take ownership of writer data (if local this actually has content)

Source

pub fn write_tile(&mut self, tile_id: u64, data: &[u8], face: Option<Face>)

Write a tile to the PMTiles file given its tile ID.

Trait Implementations§

Source§

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

Source§

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

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

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

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.
Source§

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

Write the metadata to the folder location.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<W> UnwindSafe for PMTilesWriter<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