use OSM speed limit when available

This commit is contained in:
Dustin Carlino 2018-10-18 12:34:11 -07:00
parent 94863b7bcc
commit 1208fcea8b

View File

@ -227,6 +227,18 @@ impl Road {
}
pub fn get_speed_limit(&self) -> si::MeterPerSecond<f64> {
// TODO Should probably cache this
if let Some(limit) = self.osm_tags.get("maxspeed") {
// TODO handle other units
if limit.ends_with(" mph") {
if let Ok(mph) = limit[0..limit.len() - 4].parse::<f64>() {
// TODO rm after verifying
println!("parsed {} mph", mph);
return mph * 0.44704 * si::MPS;
}
}
}
if self.osm_tags.get("highway") == Some(&"primary".to_string())
|| self.osm_tags.get("highway") == Some(&"secondary".to_string())
{