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:
PMTilesWriter::new: Create a new PMTilesWriterPMTilesWriter::take: Take ownership of the data (assuming local buffered data and not a filesystem writer)PMTilesWriter::write_tile: Write a tile to the PMTiles file given its tile ID.PMTilesWriter::write_tile_wm: Write a Web Mercator tile to the folder location given its (zoom, x, y) coordinates.PMTilesWriter::write_tile_s2: Write a S2 tile to the folder location given its (face, zoom, x, y) coordinates.PMTilesWriter::commit: Write the metadata to the folder location.
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>
impl<W: Writer> PMTilesWriter<W>
Sourcepub fn new(writer: W, compression: CompressionFormat) -> Self
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.
Trait Implementations§
Source§impl<W: Writer> TileWriter for PMTilesWriter<W>
impl<W: Writer> TileWriter for PMTilesWriter<W>
Source§fn write_tile_wm(&mut self, zoom: u8, x: u32, y: u32, data: Vec<u8>)
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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