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:
S2TilesWriter::new: Create a new S2TilesWriterS2TilesWriter::write_tile_wm: Write a Web Mercator tile to the folder location given its (zoom, x, y) coordinates.S2TilesWriter::write_tile_s2: Write a S2 tile to the folder location given its (face, zoom, x, y) coordinates.S2TilesWriter::commit: Write the metadata to the folder location.S2TilesWriter::writer: Borrow the writer mutably if neededS2TilesWriter::put_tile_fzxy: Write a tile to the S2Tiles file given its (face, zoom, x, y) coordinates.S2TilesWriter::put_tile: Inserts a tile into the S2Tiles store.
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);§Links
- https://github.com/Open-S2/s2tiles/blob/master/s2tiles-spec/1.0.0/README.md
Implementations§
Source§impl<W: Writer> S2TilesWriter<W>
impl<W: Writer> S2TilesWriter<W>
Sourcepub fn new(writer: W, maxzoom: u8, compression: CompressionFormat) -> Self
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
Sourcepub fn put_tile_fzxy(
&mut self,
face: Face,
zoom: u8,
x: u32,
y: u32,
data: Vec<u8>,
)
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 facezoom: the zoom levelx: the tile X coordinatey: the tile Y coordinatedata: the tile data to store
Trait Implementations§
Source§impl<W: Writer> TileWriter for S2TilesWriter<W>
impl<W: Writer> TileWriter for S2TilesWriter<W>
Source§fn commit(
&mut self,
metadata: Metadata,
tile_compression: Option<CompressionFormat>,
)
fn commit( &mut self, metadata: Metadata, tile_compression: Option<CompressionFormat>, )
Finish writing by building the header with root and leaf directories
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> 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