mvt 0.5.2

A library for encoding mapbox vector tiles
Documentation

mvt

A library for encoding mapbox vector tiles (MVT). Version 2.1 of the standard is supported.

The API is designed to prevent creating files which are not allowed by the specification.

Example

use mvt::{Error, GeomEncoder, GeomType, Tile, Transform};

fn main() -> Result<(), Error> {
    let mut tile = Tile::new(4096);
    let layer = tile.create_layer("First Layer");
    let b = GeomEncoder::new(GeomType::Linestring, Transform::new())
                        .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(())
}

Alternatives

These are other rust projects with MVT support: