osm_xml/
elements.rs

1use polygon;
2
3pub type Coordinate = f64;
4pub type Id = i64;
5pub type Role = String;
6
7#[derive(Debug, PartialEq, Clone)]
8pub struct Tag {
9    pub key: String,
10    pub val: String,
11}
12
13#[derive(Debug, PartialEq, Copy, Clone)]
14pub struct Bounds {
15    pub minlat: Coordinate,
16    pub minlon: Coordinate,
17    pub maxlat: Coordinate,
18    pub maxlon: Coordinate,
19}
20
21#[derive(Debug, PartialEq, Clone)]
22pub struct Node {
23    pub id: Id,
24    pub lat: Coordinate,
25    pub lon: Coordinate,
26    pub tags: Vec<Tag>,
27}
28
29#[derive(Debug, PartialEq, Clone)]
30pub struct Way {
31    pub id: Id,
32    pub tags: Vec<Tag>,
33    pub nodes: Vec<UnresolvedReference>,
34}
35
36impl Way {
37    pub fn is_polygon(&self) -> bool {
38        polygon::is_polygon(self)
39    }
40}
41
42#[derive(Debug, PartialEq, Clone)]
43pub struct Relation {
44    pub id: Id,
45    pub members: Vec<Member>,
46    pub tags: Vec<Tag>,
47}
48
49#[derive(Debug, PartialEq, Clone)]
50pub enum Member {
51    Node(UnresolvedReference, Role),
52    Way(UnresolvedReference, Role),
53    Relation(UnresolvedReference, Role),
54}
55
56#[derive(Debug, PartialEq, Copy, Clone)]
57pub enum UnresolvedReference {
58    Node(Id),
59    Way(Id),
60    Relation(Id),
61}
62
63#[derive(Debug, PartialEq, Clone)]
64pub enum Reference<'a> {
65    Node(&'a Node),
66    Way(&'a Way),
67    Relation(&'a Relation),
68    Unresolved,
69}