come up with some building address when there are no building tags

This commit is contained in:
Dustin Carlino 2019-12-02 15:00:53 -08:00
parent 3267ec4068
commit b533377159
3 changed files with 16 additions and 23 deletions

View File

@ -115,7 +115,7 @@ impl CommonState {
osd.append_all(vec![
Line(b.to_string()).fg(id_color),
Line(" is "),
Line(bldg.get_name()).fg(name_color),
Line(bldg.get_name(map)).fg(name_color),
]);
if let Some(ref p) = bldg.parking {
osd.append(Line(format!(

View File

@ -16,11 +16,8 @@ pub struct TripExplorer {
impl TripExplorer {
pub fn new(trip: TripID, ctx: &mut EventCtx, ui: &UI) -> TripExplorer {
let phases = ui
.primary
.sim
.get_analytics()
.get_trip_phases(trip, &ui.primary.map);
let map = &ui.primary.map;
let phases = ui.primary.sim.get_analytics().get_trip_phases(trip, map);
// TODO Hack because ColorLegend only takes &str
let mut rows = Vec::new();
for (idx, p) in phases.iter().enumerate() {
@ -33,7 +30,7 @@ impl TripExplorer {
let mut zoomed = GeomBatch::new();
for (p, (_, color)) in phases.iter().zip(rows.iter()) {
if let Some((dist, ref path)) = p.path {
if let Some(t) = path.trace(&ui.primary.map, dist, None) {
if let Some(t) = path.trace(map, dist, None) {
unzoomed.push(*color, t.make_polygons(Distance::meters(10.0)));
zoomed.push(*color, t.make_polygons(Distance::meters(1.0)));
}
@ -45,13 +42,13 @@ impl TripExplorer {
let start_color = rotating_color_map(0);
match trip_start {
TripStart::Bldg(b) => {
let bldg = ui.primary.map.get_b(b);
rows.insert(0, (format!("start at {}", bldg.get_name()), start_color));
let bldg = map.get_b(b);
rows.insert(0, (format!("start at {}", bldg.get_name(map)), start_color));
unzoomed.push(start_color, bldg.polygon.clone());
zoomed.push(start_color, bldg.polygon.clone());
}
TripStart::Border(i) => {
let i = ui.primary.map.get_i(i);
let i = map.get_i(i);
rows.insert(0, (format!("enter map via {}", i.id), start_color));
unzoomed.push(start_color, i.polygon.clone());
zoomed.push(start_color, i.polygon.clone());
@ -59,12 +56,7 @@ impl TripExplorer {
};
// Is the trip ongoing?
if let Some(pt) = ui
.primary
.sim
.get_canonical_pt_per_trip(trip, &ui.primary.map)
.ok()
{
if let Some(pt) = ui.primary.sim.get_canonical_pt_per_trip(trip, map).ok() {
let color = rotating_color_map(rows.len());
unzoomed.push(color, Circle::new(pt, Distance::meters(10.0)).to_polygon());
zoomed.push(
@ -77,13 +69,13 @@ impl TripExplorer {
let end_color = rotating_color_map(rows.len());
match trip_end {
TripEnd::Bldg(b) => {
let bldg = ui.primary.map.get_b(b);
rows.push((format!("end at {}", bldg.get_name()), end_color));
let bldg = map.get_b(b);
rows.push((format!("end at {}", bldg.get_name(map)), end_color));
unzoomed.push(end_color, bldg.polygon.clone());
zoomed.push(end_color, bldg.polygon.clone());
}
TripEnd::Border(i) => {
let i = ui.primary.map.get_i(i);
let i = map.get_i(i);
rows.push((format!("leave map via {}", i.id), end_color));
unzoomed.push(end_color, i.polygon.clone());
zoomed.push(end_color, i.polygon.clone());
@ -92,7 +84,7 @@ impl TripExplorer {
// something instead
TripEnd::ServeBusRoute(br) => {
rows.push((
format!("serve route {} forever", ui.primary.map.get_br(br).name),
format!("serve route {} forever", map.get_br(br).name),
end_color,
));
}

View File

@ -1,4 +1,4 @@
use crate::{osm, LaneID, Position};
use crate::{osm, LaneID, Map, Position};
use geom::{Line, Polygon, Pt2D};
use serde_derive::{Deserialize, Serialize};
use std::collections::BTreeMap;
@ -54,14 +54,15 @@ impl Building {
self.front_path.sidewalk.lane()
}
pub fn get_name(&self) -> String {
// TODO Cache?
pub fn get_name(&self, map: &Map) -> String {
let address = match (
self.osm_tags.get("addr:housenumber"),
self.osm_tags.get("addr:street"),
) {
(Some(num), Some(st)) => format!("{} {}", num, st),
(None, Some(st)) => format!("??? {}", st),
_ => "???".to_string(),
_ => format!("??? {}", map.get_parent(self.sidewalk()).get_name()),
};
if let Some(name) = self.osm_tags.get(osm::NAME) {
format!("{} (at {})", name, address)