Skip to content

Commit 5904751

Browse files
committed
[pre] add street-kinds
1 parent 5aa8dca commit 5904751

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

pre/src/main.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,36 @@ fn aproximate_speed_limit(s: &str) -> usize {
100100
}
101101
}
102102

103+
/// get what kind of street it is:
104+
/* infos from https://wiki.openstreetmap.org/wiki/Key:highway
105+
0 = car only
106+
1 = car and bicycle
107+
2 = bicycle
108+
3 = bicycle and pedestrian
109+
4 = pedestrian
110+
5 = all
111+
100 = skip
112+
*/
113+
fn get_street_kind(s: &str) -> usize {
114+
match s {
115+
"motorway" | "motorway_link" => return 0,
116+
"trunk" | "trunk_link" => return 0,
117+
"raceway" | "services" | "rest_area" => 0,
118+
"primary" | "primary_link" => return 1,
119+
"secondary" | "secondary_link" => return 1,
120+
"tertiary" | "tertiary_link" => return 1,
121+
"cycleway" => return 2,
122+
"trail" | "track" | "path" => 3,
123+
"elevator" | "platform" | "corridor" => 4,
124+
"bus_stop" | "bridleway" | "steps" | "pedestrian" | "footway" => return 4,
125+
"unclassified" => return 5,
126+
"residential" | "living_street" => return 5,
127+
"service" | "road" => return 5,
128+
"razed" | "abandoned" | "disused" | "construction" | "proposed" => 100,
129+
_ => return 5,
130+
}
131+
}
132+
103133
fn main() {
104134
let mut ways = Vec::<Way>::new();
105135
let mut nodes = Vec::<Node>::new();
@@ -136,6 +166,10 @@ fn main() {
136166
for way in groups::ways(&group, &block) {
137167
if way.tags.contains_key("highway") {
138168
let highway = way.tags.get("highway").unwrap().trim();
169+
let kind = get_street_kind(highway);
170+
if kind == 100 {
171+
continue;
172+
}
139173
let mut max_speed: &str = "";
140174
if way.tags.contains_key("maxspeed") {
141175
max_speed = way.tags.get("maxspeed").unwrap().trim();
@@ -167,8 +201,7 @@ fn main() {
167201
target: id,
168202
speed: speed,
169203
distance: 0,
170-
// TODO add what kind of street it is
171-
kind: 1,
204+
kind: kind,
172205
});
173206
prev_id = id;
174207
}

0 commit comments

Comments
 (0)