-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify Distance implementation, and get rid of AvoidMainRoads. Move
some filtering logic into the LTS definition.
- Loading branch information
1 parent
8717d73
commit 1533e57
Showing
9 changed files
with
75 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
use crate::{Tags, LTS}; | ||
use crate::{is_cycling_allowed, parse, Tags, LTS}; | ||
|
||
pub fn speed_limit_only(tags: &Tags) -> (LTS, Vec<String>) { | ||
let msgs = vec!["Only looking at maxspeed".into()]; | ||
// TODO Handle bicycle=no, on things like highway=footway | ||
let mut msgs = vec!["Only looking at maxspeed".into()]; | ||
|
||
// TODO Use parse::get_maxspeed_mph | ||
if let Some(mph) = tags | ||
.get("maxspeed") | ||
.and_then(|x| x.trim_end_matches(" mph").parse::<usize>().ok()) | ||
{ | ||
if mph <= 20 { | ||
return (LTS::LTS2, msgs); | ||
} | ||
if mph >= 40 { | ||
return (LTS::LTS4, msgs); | ||
} | ||
// Between 20 and 40 | ||
return (LTS::LTS3, msgs); | ||
if !is_cycling_allowed(tags, &mut msgs) { | ||
return (LTS::NotAllowed, msgs); | ||
} | ||
|
||
/*if tags.is("highway", "residential") { | ||
return LTS::LTS1; | ||
}*/ | ||
|
||
(LTS::NotAllowed, msgs) | ||
let mph = parse::get_maxspeed_mph(tags, &mut msgs); | ||
if mph <= 20 { | ||
return (LTS::LTS2, msgs); | ||
} | ||
if mph >= 40 { | ||
return (LTS::LTS4, msgs); | ||
} | ||
// Between 20 and 40 | ||
(LTS::LTS3, msgs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters