Struct mvt::Layer

source ·
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

source

pub fn name(&self) -> Option<&str>

Get the layer name.

source

pub fn num_features(&self) -> usize

Get number of features (count).

source

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)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() -> Result<(), Error> {
    let mut tile = Tile::new(4096);
    let layer = tile.create_layer("First Layer");
    // NOTE: normally, the Transform would come from MapGrid::tile_transform
    let b = GeomEncoder::new(GeomType::Linestring)
        .point(0.0, 0.0)?
        .point(1024.0, 0.0)?
        .point(1024.0, 2048.0)?
        .point(2048.0, 2048.0)?
        .point(2048.0, 4096.0)?
        .encode()?;
    let mut feature = layer.into_feature(b);
    feature.set_id(1);
    feature.add_tag_string("key", "value");
    let layer = feature.into_layer();
    tile.add_layer(layer)?;
    let data = tile.to_bytes()?;
    println!("encoded {} bytes: {:?}", data.len(), data);
    Ok(())
}

Trait Implementations§

source§

impl Default for Layer

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.