Skip to content

Commit e442de7

Browse files
committed
[pre] add sidewalk option, but is not working as expected
1 parent ce4f4d0 commit e442de7

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

pre/src/main.rs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,33 @@ fn aproximate_speed_limit(s: &str) -> usize {
107107
5 = all
108108
100 = skip
109109
*/
110-
fn get_street_kind(s: &str) -> usize {
111-
match s {
112-
"motorway" | "motorway_link" => return 0,
113-
"trunk" | "trunk_link" => return 0,
110+
fn get_street_type(s: &str, has_sidewalk: bool) -> usize {
111+
let mut result = match s {
112+
"motorway" | "motorway_link" => 0,
113+
"trunk" | "trunk_link" => 0,
114114
"raceway" | "services" | "rest_area" => 0,
115-
"primary" | "primary_link" => return 1,
116-
"secondary" | "secondary_link" => return 1,
117-
"tertiary" | "tertiary_link" => return 1,
118-
"cycleway" => return 2,
115+
"primary" | "primary_link" => 1,
116+
"secondary" | "secondary_link" => 1,
117+
"tertiary" | "tertiary_link" => 1,
118+
"cycleway" => 2,
119119
"trail" | "track" | "path" => 3,
120120
"elevator" | "platform" | "corridor" => 4,
121-
"bus_stop" | "bridleway" | "steps" | "pedestrian" | "footway" => return 4,
122-
"unclassified" => return 5,
123-
"residential" | "living_street" => return 5,
124-
"service" | "road" => return 5,
121+
"bus_stop" | "bridleway" | "steps" | "pedestrian" | "footway" => 4,
122+
"unclassified" => 5,
123+
"residential" | "living_street" => 5,
124+
"service" | "road" => 5,
125125
"razed" | "abandoned" | "disused" | "construction" | "proposed" => 100,
126-
_ => return 5,
126+
_ => 5,
127+
};
128+
if has_sidewalk {
129+
result = match result {
130+
1 => 5,
131+
2 => 3,
132+
3 => 5,
133+
_ => result,
134+
}
127135
}
136+
return result;
128137
}
129138

130139
fn main() {
@@ -163,7 +172,14 @@ fn main() {
163172
for way in groups::ways(&group, &block) {
164173
if way.tags.contains_key("highway") {
165174
let highway = way.tags.get("highway").unwrap().trim();
166-
let travel_type = get_street_kind(highway);
175+
let mut has_sidewalk: bool = false;
176+
if way.tags.contains_key("sidewalk") {
177+
has_sidewalk = match way.tags.get("sidewalk").unwrap().trim() {
178+
"None" | "none" | "No" | "no" => false,
179+
_ => true,
180+
}
181+
}
182+
let travel_type = get_street_type(highway, has_sidewalk);
167183
if travel_type == 100 {
168184
continue;
169185
}

0 commit comments

Comments
 (0)