[][src]Struct vadeen_osm::OsmBuilder

pub struct OsmBuilder { /* fields omitted */ }

OsmBuilder makes it easy to build OSM maps from non OSM data. Polygons, multi polygons, poly lines and points are all represented as lists of coordinates.

Nodes are automatically added and assigned ids. Ways and relations are automatically created with the correct references.

When building maps from OSM data the elements should be added directly to an Osm struct to preserve ids. You can also use the osm_io module which do exactly that when reading data.

Examples

let mut builder = OsmBuilder::default();

// Add a polygon, which is represented as a way and two nodes in osm.
builder.add_polygon(
    &[vec![(1.0, 1.0).into(), (2.0, 2.0).into()]],
    &[("key".to_owned(), "value".to_owned())]
);

let osm = builder.build();
assert_eq!(osm.nodes.len(), 2);
assert_eq!(osm.ways.len(), 1);
assert_eq!(osm.relations.len(), 0);

let boundary = osm.boundary.unwrap();
assert_eq!(boundary.min, (1.0, 1.0).into());
assert_eq!(boundary.max, (2.0, 2.0).into());

Methods

impl OsmBuilder[src]

pub fn build(self) -> Osm[src]

pub fn add_polygon(
    &mut self,
    parts: &[Vec<Coordinate>],
    tags: &[(String, String)]
)
[src]

pub fn add_polyline(
    &mut self,
    coordinates: &[Coordinate],
    tags: &[(String, String)]
) -> i64
[src]

Trait Implementations

impl Default for OsmBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.