23 releases
Uses new Rust 2024
| new 0.11.0 | Mar 10, 2026 |
|---|---|
| 0.10.3 | Jun 25, 2025 |
| 0.10.1 | Mar 23, 2025 |
| 0.9.5 | Nov 21, 2024 |
| 0.5.2 | Feb 28, 2019 |
#319 in Encoding
4,602 downloads per month
Used in 4 crates
62KB
1.5K
SLoC
mvt
A Rust library for encoding mapbox vector tiles. Version 2.1 of the standard is supported. See documentation for details.
wyrmcast is a tile server using this crate.
lib.rs:
A library for encoding mapbox vector tiles.
A tile is composed of one or more layers. Each layer can have any number of features, which contain the geometry to be rendered. They can also have metadata tags, which are key/value pairs.
Example
use mvt::{Error, GeomEncoder, GeomType, Tile};
use pointy::Transform;
fn main() -> Result<(), Error> {
let mut tile = Tile::new(4096);
let layer = tile.create_layer("First Layer");
// NOTE: normally, the `Transform` would come from
// `squarepeg::MapGrid::transform_peg`
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(())
}
Dependencies
~2–15MB
~177K SLoC