mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
display OSM tags and road names in synthetic. it's slowly becoming like fix_map_geom, i bet
This commit is contained in:
parent
dd6db94fa0
commit
95545863fc
@ -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<String>,
|
||||
back_label: Option<String>,
|
||||
osm_tags: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
impl Road {
|
||||
fn lanes(&self, id: StableRoadID, model: &Model) -> Vec<Object<ID>> {
|
||||
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<String, String> {
|
||||
&self.roads[&id].osm_tags
|
||||
}
|
||||
}
|
||||
|
||||
impl Model {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user