Skip to content

Rust library for building Mapbox Vector Tiles from PostGIS. Help wanted to support non-postgis shapes.

License

Notifications You must be signed in to change notification settings

wyyerd/vectortile-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vectortile-rs

vectortile on crates.io vectortile on docs.rs

Rust library for building Mapbox Vector Tiles from PostGIS. This library was adapted from the MVT implementation in Pirmin Kalberer's t-rex server, with changes intended to improve usage ergonomics.

Usage

Put this in your Cargo.toml:

[dependencies]
vectortile = "0.2.2"

And this in your crate root:

extern crate vectortile;

Example

See examples/streets.rs for a full example w/ PostGIS.

This example shows creating Features and Tiles programmatically:

use vectortile::{Tile, Layer, Feature, Value};
use vectortile::geom::{Geometry, Point};
use vectortile::grid::{Grid, Extent};
use postgis::ewkb;

// Build a new tile, the hard way
let bbox = Extent{minx: 958826.08, miny: 5987771.04, maxx: 978393.96, maxy: 6007338.92};
let mut tile = Tile::new(&bbox);
let mut layer = Layer::new("place");
tile.add_layer(layer);

// Add a new point feature "Ed's Mospresso Shack"
let geom: Geometry = ewkb::GeometryT::Point(Point::new(960000.0, 6002729.0, Some(3857)));
let mut feature = Feature::new(geom);
feature.add_property("place", Value::String(String::from("business")));
feature.add_property("name", Value::String(String::from("Ed's Mospresso Shack")));
layer.add_feature(feature);

// Encode the tile as protobuf and inspect it
let grid = Grid::wgs84();
let data = tile.encode(&grid);
println!("{:#?}", data);

About

Rust library for building Mapbox Vector Tiles from PostGIS. Help wanted to support non-postgis shapes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages