displaying names for more roads

This commit is contained in:
Dustin Carlino 2019-05-04 10:56:53 -07:00
parent 71be19163d
commit cca6f4b5ec
3 changed files with 31 additions and 4 deletions

View File

@ -5,6 +5,7 @@
- need intersection merging before this is understandable
- close interior neighborhoods to most cars (except for src/dst), see how traffic restricted to arterials would work
- puzzle: with only X miles of retained road, where would you leave them? what roads would go away?
- parking garages on the edges of neighborhoods?
- create a bike network with minimal hills, dedicated roads, minimal crossings
- easter eggs

View File

@ -126,6 +126,12 @@ pub fn make_half_map(
bus_stops: Vec::new(),
});
}
if road.get_name() == "???" {
timer.warn(format!(
"{} has no name. Tags: {:?}",
road.id, road.osm_tags
));
}
half_map.roads.push(road);
}

View File

@ -333,9 +333,29 @@ impl Road {
}
pub fn get_name(&self) -> String {
self.osm_tags
.get("name")
.unwrap_or(&"???".to_string())
.to_string()
if let Some(name) = self.osm_tags.get("name") {
return name.to_string();
}
if let Some(name) = self.osm_tags.get("ref") {
return name.to_string();
}
if self
.osm_tags
.get("highway")
.map(|hwy| hwy.ends_with("_link"))
.unwrap_or(false)
{
if let Some(name) = self.osm_tags.get("destination:street") {
return format!("Exit for {}", name);
}
if let Some(name) = self.osm_tags.get("destination:ref") {
return format!("Exit for {}", name);
}
if let Some(name) = self.osm_tags.get("destination") {
return format!("Exit for {}", name);
}
// Sometimes 'directions' is filled out, but incorrectly...
}
"???".to_string()
}
}