mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
plugin to show original road centers at the end
This commit is contained in:
parent
5bf4a711b1
commit
bb6f5e0af0
@ -8,11 +8,14 @@
|
||||
- bad polyline shifting causes jagged lane endings in generalized_trim_back
|
||||
|
||||
- handle small roads again somehow?
|
||||
- what's going on with O253 generally?
|
||||
- the base geometry in OSM is just wrong... because ways have to be connected at the center lines
|
||||
- one-lane coming off a 4 or 5 lane and going one way... maybe it should be shifted to the other side
|
||||
- that messes up the nice curve later. need to clip, not shift.
|
||||
- o123 is a pretty weird shape, it eats the entire curve
|
||||
- did the second_half stuff mess things up?
|
||||
- o40 has a long cut when merged, why not hit in the middle?
|
||||
- what if we allow intersections between infinite lines for merged cases?
|
||||
- what's going on with O253 generally?
|
||||
- need a way to see the original untrimmed roads... want to draw them at the end, in a plugin
|
||||
- experiment with resolution
|
||||
- try it bigger
|
||||
- deal with loop roads?
|
||||
|
||||
|
@ -49,7 +49,7 @@ Seattlites with opinions and ideas:
|
||||
|
||||
* https://github.com/uwescience/TrafficCruising-DSSG2017
|
||||
* http://sharedstreets.io/
|
||||
|
||||
* https://github.com/twpol/osm-tiles attempting to infer nice road geometry too
|
||||
|
||||
## Notes from related work
|
||||
|
||||
|
@ -6,4 +6,5 @@ pub mod floodfill;
|
||||
pub mod geom_validation;
|
||||
pub mod hider;
|
||||
pub mod layers;
|
||||
pub mod orig_roads;
|
||||
pub mod spawn_agent;
|
||||
|
74
editor/src/plugins/debug/orig_roads.rs
Normal file
74
editor/src/plugins/debug/orig_roads.rs
Normal file
@ -0,0 +1,74 @@
|
||||
use crate::objects::{Ctx, ID};
|
||||
use crate::plugins::PluginCtx;
|
||||
use ezgui::{Color, GfxCtx, Key};
|
||||
use geom::Distance;
|
||||
use map_model::{RoadID, LANE_THICKNESS};
|
||||
use std::collections::HashSet;
|
||||
|
||||
pub struct ShowOriginalRoads {
|
||||
roads: HashSet<RoadID>,
|
||||
}
|
||||
|
||||
impl ShowOriginalRoads {
|
||||
pub fn new(ctx: &mut PluginCtx) -> Option<ShowOriginalRoads> {
|
||||
if let Some(id) = show_road(ctx) {
|
||||
let mut roads = HashSet::new();
|
||||
roads.insert(id);
|
||||
return Some(ShowOriginalRoads { roads });
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn nonblocking_event(&mut self, ctx: &mut PluginCtx) -> bool {
|
||||
ctx.input.set_mode("Original Roads", &ctx.canvas);
|
||||
|
||||
if ctx.input.modal_action("quit") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(id) = show_road(ctx) {
|
||||
self.roads.insert(id);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
|
||||
for id in &self.roads {
|
||||
let r = ctx.map.get_r(*id);
|
||||
// TODO Should be a less tedious way to do this
|
||||
let width_right = (r.children_forwards.len() as f64) * LANE_THICKNESS;
|
||||
let width_left = (r.children_backwards.len() as f64) * LANE_THICKNESS;
|
||||
if width_right != Distance::ZERO {
|
||||
g.draw_polygon(
|
||||
ctx.cs
|
||||
.get_def("original road forwards", Color::RED.alpha(0.5)),
|
||||
&r.original_center_pts
|
||||
.shift_right(width_right / 2.0)
|
||||
.make_polygons(width_right),
|
||||
);
|
||||
}
|
||||
if width_left != Distance::ZERO {
|
||||
g.draw_polygon(
|
||||
ctx.cs
|
||||
.get_def("original road backwards", Color::BLUE.alpha(0.5)),
|
||||
&r.original_center_pts
|
||||
.shift_left(width_left / 2.0)
|
||||
.make_polygons(width_left),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn show_road(ctx: &mut PluginCtx) -> Option<RoadID> {
|
||||
if let Some(ID::Lane(l)) = ctx.primary.current_selection {
|
||||
let id = ctx.primary.map.get_l(l).parent;
|
||||
if ctx
|
||||
.input
|
||||
.contextual_action(Key::V, &format!("show original geometry of {:?}", id))
|
||||
{
|
||||
return Some(id);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
@ -365,6 +365,21 @@ impl UIState for DefaultUIState {
|
||||
self.primary_plugins.hider = Some(p);
|
||||
}
|
||||
}
|
||||
if self.primary_plugins.orig_roads.is_some() {
|
||||
if !self
|
||||
.primary_plugins
|
||||
.orig_roads
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.nonblocking_event(&mut ctx)
|
||||
{
|
||||
self.primary_plugins.orig_roads = None;
|
||||
}
|
||||
} else if self.enable_debug_controls {
|
||||
if let Some(p) = debug::orig_roads::ShowOriginalRoads::new(&mut ctx) {
|
||||
self.primary_plugins.orig_roads = Some(p);
|
||||
}
|
||||
}
|
||||
|
||||
// Ambient plugins
|
||||
self.sim_controls
|
||||
@ -400,6 +415,9 @@ impl UIState for DefaultUIState {
|
||||
if let Some(ref p) = self.legend {
|
||||
p.draw(g, ctx);
|
||||
}
|
||||
if let Some(ref p) = self.primary_plugins.orig_roads {
|
||||
p.draw(g, ctx);
|
||||
}
|
||||
// Hider doesn't draw
|
||||
|
||||
if self.primary_plugins.simple_model.is_active() {
|
||||
@ -461,6 +479,7 @@ pub struct PluginsPerMap {
|
||||
// These are stackable modal plugins. They can all coexist, and they don't block other modal
|
||||
// plugins or ambient plugins.
|
||||
hider: Option<debug::hider::Hider>,
|
||||
orig_roads: Option<debug::orig_roads::ShowOriginalRoads>,
|
||||
|
||||
// When present, this either acts like exclusive blocking or like stackable modal. :\
|
||||
search: Option<view::search::SearchState>,
|
||||
@ -476,6 +495,7 @@ impl PluginsPerMap {
|
||||
pub fn new(state: &PerMapUI, timer: &mut Timer, enable_debug_controls: bool) -> PluginsPerMap {
|
||||
let mut p = PluginsPerMap {
|
||||
hider: None,
|
||||
orig_roads: None,
|
||||
search: None,
|
||||
ambient_plugins: vec![
|
||||
Box::new(view::follow::FollowState::new()),
|
||||
|
@ -155,6 +155,7 @@ impl<S: UIState> GUI<RenderingHints> for UI<S> {
|
||||
"Geometry Debugger",
|
||||
vec![(Key::Enter, "quit"), (Key::N, "see next problem")],
|
||||
),
|
||||
ModalMenu::new("Original Roads", vec![(Key::Enter, "quit")]),
|
||||
ModalMenu::new("OSM Classifier", vec![(Key::Num6, "quit")]),
|
||||
ModalMenu::new(
|
||||
"Floodfiller",
|
||||
|
@ -52,6 +52,10 @@ impl Line {
|
||||
let head_size = thickness * 2.0;
|
||||
let angle = self.angle();
|
||||
let triangle_height = (head_size / 2.0).sqrt();
|
||||
if self.length() < triangle_height {
|
||||
println!("Can't make_arrow of thickness {} for {}", thickness, self);
|
||||
return Vec::new();
|
||||
}
|
||||
vec![
|
||||
Polygon::new(&vec![
|
||||
//self.pt2(),
|
||||
|
@ -85,6 +85,7 @@ pub fn make_half_map(
|
||||
children_forwards: Vec::new(),
|
||||
children_backwards: Vec::new(),
|
||||
center_pts: r.trimmed_center_pts.clone(),
|
||||
original_center_pts: r.original_center_pts.clone(),
|
||||
src_i: i1,
|
||||
dst_i: i2,
|
||||
};
|
||||
|
@ -105,6 +105,18 @@ impl InitialMap {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO I can't find anything online that describes how to interpret the given OSM
|
||||
// geometry of one-ways. I'm interpreting the way as the edge of the road (and only
|
||||
// shift_right()ing from there). But could also uncomment this and interpret the way as
|
||||
// the actual center of the one-way road. It looks quite bad -- dual carriageways get
|
||||
// smooshed together.
|
||||
/*assert_ne!(fwd_width, Distance::ZERO);
|
||||
if back_width == Distance::ZERO {
|
||||
// Interpret the original OSM geometry of one-ways as the actual center of the
|
||||
// road.
|
||||
original_center_pts = original_center_pts.shift_left(fwd_width / 2.0);
|
||||
}*/
|
||||
|
||||
m.roads.insert(
|
||||
*stable_id,
|
||||
Road {
|
||||
|
@ -32,6 +32,9 @@ pub struct Road {
|
||||
pub center_pts: PolyLine,
|
||||
pub src_i: IntersectionID,
|
||||
pub dst_i: IntersectionID,
|
||||
|
||||
// For debugging.
|
||||
pub original_center_pts: PolyLine,
|
||||
}
|
||||
|
||||
impl Road {
|
||||
|
Loading…
Reference in New Issue
Block a user