[−][src]Struct vadeen_osm::OsmBuilder
OsmBuilder
makes it easy to build OSM maps from non OSM data. Polygons, multi polygons,
poly lines and points are all represented as vectors 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 point, represented as one node. builder.add_point((2.0, 2.0), vec![("power", "tower")]); // Add a poly line, represented as two nodes and a way. builder.add_polyline( vec![(2.0, 2.0), (4.0, 5.0)], vec![("power", "line")] ); // Add a polygon, which is represented as one way and two nodes in osm. builder.add_polygon( vec![ // Outer polygon vec![(1.0, 1.0), (10.0, 10.0), (5.0, 5.0), (1.0, 1.0)], // If you want inner polygons, add them here... // Each inner polygon is represented as a way, the polygons are connected by a relation. ], vec![("natural", "water")] ); let osm = builder.build(); assert_eq!(osm.nodes.len(), 5); assert_eq!(osm.ways.len(), 2); assert_eq!(osm.relations.len(), 0); assert_eq!(osm.boundary, Some(Boundary::new((1.0, 1.0), (10.0, 10.0))));
Implementations
impl OsmBuilder
[src]
pub fn build(self) -> Osm
[src]
pub fn add_point<C: Into<Coordinate>, T: Into<Tag>>(
&mut self,
coordinate: C,
tags: Vec<T>
)
[src]
&mut self,
coordinate: C,
tags: Vec<T>
)
pub fn add_polygon<C, T>(&mut self, parts: Vec<Vec<C>>, tags: Vec<T>) where
C: Into<Coordinate>,
T: Into<Tag>,
[src]
C: Into<Coordinate>,
T: Into<Tag>,
First part is the outer polygon, rest of the parts is inner polygons.
parts
must not be empty or a panic will occur.
pub fn add_polyline<C, T>(&mut self, coordinates: Vec<C>, tags: Vec<T>) -> i64 where
C: Into<Coordinate>,
T: Into<Tag>,
[src]
C: Into<Coordinate>,
T: Into<Tag>,
Trait Implementations
impl Default for OsmBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for OsmBuilder
[src]
impl Send for OsmBuilder
[src]
impl Sync for OsmBuilder
[src]
impl Unpin for OsmBuilder
[src]
impl UnwindSafe for OsmBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,