-
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.
Clearly split out 'plugin' code that should likely be edited by someone
- Loading branch information
1 parent
4b4757a
commit bbed56a
Showing
7 changed files
with
76 additions
and
57 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ mod node_map; | |
mod od; | ||
mod osm2network; | ||
mod osrm; | ||
mod plugins; | ||
mod requests; | ||
mod tags; | ||
|
||
|
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,27 @@ | ||
use crate::tags::Tags; | ||
|
||
// 1 suitable for kids, 4 high stress, 0 is unknown. Need to swap this out for something much | ||
// better, and maybe make it directional! | ||
pub fn placeholder(tags: Tags) -> usize { | ||
// TODO Handle bicycle=no, on things like highway=footway | ||
|
||
if let Some(mph) = tags | ||
.get("maxspeed") | ||
.and_then(|x| x.trim_end_matches(" mph").parse::<usize>().ok()) | ||
{ | ||
if mph <= 20 { | ||
return 2; | ||
} | ||
if mph >= 40 { | ||
return 4; | ||
} | ||
// Between 20 and 40 | ||
return 3; | ||
} | ||
|
||
/*if tags.is("highway", "residential") { | ||
return 1; | ||
}*/ | ||
|
||
0 // TODO unknown | ||
} |
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,3 @@ | ||
pub mod lts; | ||
pub mod route_cost; | ||
pub mod uptake; |
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,26 @@ | ||
use crate::input::CostFunction; | ||
use crate::osm2network::Edge; | ||
|
||
pub fn edge_cost(edge: &Edge, cost: CostFunction) -> Option<usize> { | ||
let tags = edge.cleaned_tags(); | ||
|
||
// TODO Match the lts.ts definition | ||
if tags.is("bicycle", "no") || tags.is("highway", "motorway") || tags.is("highway", "proposed") | ||
{ | ||
return None; | ||
} | ||
|
||
let output = match cost { | ||
CostFunction::Distance => edge.length_meters, | ||
CostFunction::AvoidMainRoads => { | ||
// TODO Match the LTS definitoins | ||
let penalty = if tags.is("highway", "residential") || tags.is("highway", "cycleway") { | ||
1.0 | ||
} else { | ||
5.0 | ||
}; | ||
penalty * edge.length_meters | ||
} | ||
}; | ||
Some(output.round() as usize) | ||
} |
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,9 @@ | ||
use crate::input::Filter; | ||
|
||
pub fn should_skip_trip(filter: &Filter, total_distance_meters: f64) -> bool { | ||
if let Some(max) = filter.max_distance_meters { | ||
return total_distance_meters.round() as usize > max; | ||
} | ||
|
||
false | ||
} |