pub struct Layer { /* private fields */ }
Expand description
A layer is a set of related features in a tile.
§Example
use mvt::Tile;
let mut tile = Tile::new(4096);
let layer = tile.create_layer("First Layer");
// ...
// set up the layer
// ...
Implementations§
Source§impl Layer
impl Layer
Sourcepub fn num_features(&self) -> usize
pub fn num_features(&self) -> usize
Get number of features (count).
Sourcepub fn into_feature(self, geom_data: GeomData) -> Feature
pub fn into_feature(self, geom_data: GeomData) -> Feature
Create a new feature, giving it ownership of the layer.
geom_data
Geometry data (consumed by this method).
Examples found in repository?
examples/simple.rs (line 14)
3fn main() -> Result<(), Error> {
4 let mut tile = Tile::new(4096);
5 let layer = tile.create_layer("First Layer");
6 // NOTE: normally, the Transform would come from MapGrid::tile_transform
7 let b = GeomEncoder::new(GeomType::Linestring)
8 .point(0.0, 0.0)?
9 .point(1024.0, 0.0)?
10 .point(1024.0, 2048.0)?
11 .point(2048.0, 2048.0)?
12 .point(2048.0, 4096.0)?
13 .encode()?;
14 let mut feature = layer.into_feature(b);
15 feature.set_id(1);
16 feature.add_tag_string("key", "value");
17 let layer = feature.into_layer();
18 tile.add_layer(layer)?;
19 let data = tile.to_bytes()?;
20 println!("encoded {} bytes: {:?}", data.len(), data);
21 Ok(())
22}
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Layer
impl RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl UnwindSafe for Layer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more