diff --git a/synthetic/src/lib.rs b/synthetic/src/lib.rs index 6a1daba80e..ddad50e6e1 100644 --- a/synthetic/src/lib.rs +++ b/synthetic/src/lib.rs @@ -1,6 +1,6 @@ use abstutil::{read_binary, Timer}; use ezgui::world::{Object, ObjectID, World}; -use ezgui::{Color, EventCtx, GfxCtx, Prerender}; +use ezgui::{Color, EventCtx, GfxCtx, Line, Prerender, Text}; use geom::{Bounds, Circle, Distance, LonLat, PolyLine, Polygon, Pt2D}; use map_model::raw_data::{StableIntersectionID, StableRoadID}; use map_model::{raw_data, IntersectionType, LaneType, RoadSpec, LANE_THICKNESS}; @@ -63,10 +63,20 @@ struct Road { lanes: RoadSpec, fwd_label: Option, back_label: Option, + osm_tags: BTreeMap, } impl Road { fn lanes(&self, id: StableRoadID, model: &Model) -> Vec> { + let mut tooltip = Text::new(); + if let Some(name) = self.osm_tags.get("name") { + tooltip.add(Line(name)); + } else if let Some(name) = self.osm_tags.get("ref") { + tooltip.add(Line(name)); + } else { + tooltip.add(Line("some road")); + } + let base = PolyLine::new(vec![ model.intersections[&self.i1].center, model.intersections[&self.i2].center, @@ -100,7 +110,7 @@ impl Road { if idx == self.lanes.fwd.len() / 2 { obj = obj.maybe_label(self.fwd_label.clone()); } - result.push(obj); + result.push(obj.tooltip(tooltip.clone())); } for (idx, lt) in self.lanes.back.iter().enumerate() { let mut obj = Object::new( @@ -114,7 +124,7 @@ impl Road { if idx == self.lanes.back.len() / 2 { obj = obj.maybe_label(self.back_label.clone()); } - result.push(obj); + result.push(obj.tooltip(tooltip.clone())); } result @@ -285,6 +295,7 @@ impl Model { lanes: r.get_spec(), fwd_label: r.osm_tags.get("fwd_label").cloned(), back_label: r.osm_tags.get("back_label").cloned(), + osm_tags: r.osm_tags.clone(), }, ); m.intersections.get_mut(&i1).unwrap().roads.insert(*id); @@ -462,6 +473,7 @@ impl Model { }, fwd_label: None, back_label: None, + osm_tags: BTreeMap::new(), }, ); self.intersections.get_mut(&i1).unwrap().roads.insert(id); @@ -529,6 +541,10 @@ impl Model { pub fn get_lanes(&self, id: StableRoadID) -> String { self.roads[&id].lanes.to_string() } + + pub fn get_tags(&self, id: StableRoadID) -> &BTreeMap { + &self.roads[&id].osm_tags + } } impl Model { diff --git a/synthetic/src/main.rs b/synthetic/src/main.rs index 3411934b55..3dfe5f17ac 100644 --- a/synthetic/src/main.rs +++ b/synthetic/src/main.rs @@ -1,4 +1,4 @@ -use ezgui::{Color, EventCtx, EventLoopMode, GfxCtx, Key, Text, Wizard, GUI}; +use ezgui::{Color, EventCtx, EventLoopMode, GfxCtx, Key, Line, Text, Wizard, GUI}; use geom::{Distance, Line}; use map_model::raw_data::{StableIntersectionID, StableRoadID}; use std::{env, process}; @@ -209,7 +209,24 @@ impl GUI for UI { | State::SavingModel(ref wizard) => { wizard.draw(g); } - _ => {} + State::Viewing => { + if let Some(ID::Lane(id, _, _)) = self.model.get_selection() { + let mut txt = Text::new(); + for (k, v) in self.model.get_tags(id) { + txt.add(Line(k).fg(Color::RED)); + txt.append(Line(" = ")); + txt.append(Line(v).fg(Color::CYAN)); + } + g.draw_blocking_text( + &txt, + ( + ezgui::HorizontalAlignment::Right, + ezgui::VerticalAlignment::Top, + ), + ); + } + } + State::MovingIntersection(_) | State::MovingBuilding(_) => {} }; g.draw_blocking_text(&self.osd, ezgui::BOTTOM_LEFT);