-
Notifications
You must be signed in to change notification settings - Fork 7
/
allowed.rs
43 lines (37 loc) · 1.17 KB
/
allowed.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::Tags;
pub fn is_cycling_allowed(tags: &Tags, msgs: &mut Vec<String>) -> bool {
if !tags.has("highway") && !tags.has("bicycle") {
msgs.push("Way doesn't have a highway or bicycle tag".into());
return false;
}
if tags.is("bicycle", "no") {
msgs.push("Cycling not permitted due to bicycle=no".into());
return false;
}
if tags.is("access", "no") {
// TODO There are exceptions for bicycle
msgs.push("Cycling not permitted due to access=no".into());
return false;
}
if tags.is_any(
"highway",
vec!["motorway", "motorway_link", "proposed", "construction"],
) {
msgs.push(format!(
"Cycling not permitted due to highway={}",
tags.get("highway").unwrap()
));
return false;
}
if tags.is_any("highway", vec!["footway", "path"])
&& tags.is("footway", "sidewalk")
&& !tags.is("bicycle", "yes")
{
msgs.push(format!(
"Cycling not permitted on highway={}, when footway=sidewalk and bicycle=yes is missing",
tags.get("highway").unwrap()
));
return false;
}
true
}