From f243048c450ef39439c3352b3cb3f427ec04f7d5 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sat, 10 Nov 2018 16:39:47 -0800 Subject: [PATCH] drawing border nodes differently --- docs/design/maps.md | 2 ++ editor/src/render/intersection.rs | 6 ++++++ map_model/src/intersection.rs | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/design/maps.md b/docs/design/maps.md index 34aa31bc6d..3a35292e81 100644 --- a/docs/design/maps.md +++ b/docs/design/maps.md @@ -282,3 +282,5 @@ can begin or end. - manually marking them? - draw the FSM for cars/peds - trips starting/ending at border nodes short-circuit some steps + +What about border nodes where the sidewalk can cross over, but the driving lane leads nowhere? diff --git a/editor/src/render/intersection.rs b/editor/src/render/intersection.rs index 15d4b98dd4..42d941efa3 100644 --- a/editor/src/render/intersection.rs +++ b/editor/src/render/intersection.rs @@ -19,6 +19,7 @@ pub struct DrawIntersection { sidewalk_corners: Vec, center: Pt2D, has_traffic_signal: bool, + is_border: bool, should_draw_stop_sign: bool, } @@ -36,6 +37,7 @@ impl DrawIntersection { crosswalks: calculate_crosswalks(inter.id, map), sidewalk_corners: calculate_corners(inter.id, map), has_traffic_signal: inter.has_traffic_signal, + is_border: inter.is_border(map), should_draw_stop_sign: !inter.has_traffic_signal && !inter.is_degenerate(), } } @@ -85,6 +87,10 @@ impl Renderable for DrawIntersection { fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx) { let color = opts.color.unwrap_or_else(|| { + if self.is_border { + return ctx.cs.get("border intersection", Color::rgb(50, 205, 50)); + } + let changed = if let Some(s) = ctx.control_map.traffic_signals.get(&self.id) { s.is_changed() } else if let Some(s) = ctx.control_map.stop_signs.get(&self.id) { diff --git a/map_model/src/intersection.rs b/map_model/src/intersection.rs index a1f9e04d0f..756ee776e3 100644 --- a/map_model/src/intersection.rs +++ b/map_model/src/intersection.rs @@ -5,7 +5,7 @@ use dimensioned::si; use geom::Pt2D; use std::collections::BTreeSet; use std::fmt; -use {LaneID, RoadID, TurnID}; +use {LaneID, Map, RoadID, TurnID}; // TODO reconsider pub usize. maybe outside world shouldnt know. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] @@ -51,6 +51,16 @@ impl Intersection { self.roads.len() == 2 } + pub fn is_border(&self, map: &Map) -> bool { + // Bias for driving + if !self.is_dead_end() { + return false; + } + let has_driving_in = self.incoming_lanes.iter().find(|l| map.get_l(**l).is_driving()).is_some(); + let has_driving_out = self.outgoing_lanes.iter().find(|l| map.get_l(**l).is_driving()).is_some(); + has_driving_in != has_driving_out + } + pub fn dump_debug(&self) { println!("{}", abstutil::to_json(self)); }