improve turn markings on lanes

This commit is contained in:
Dustin Carlino 2019-04-20 11:38:58 -07:00
parent 3364cd1d0c
commit 669fd886d5
4 changed files with 29 additions and 37 deletions

View File

@ -32,6 +32,9 @@
- yellow and white lines intersect cars and turn icons and such
- who should own drawing them?
- arrows
- sometimes head is separated from body. I314 montlake ped turn arrows
## More data
- lanes: https://data-seattlecitygis.opendata.arcgis.com/datasets/49d417979fec452981a068ca078e7070_3

View File

@ -5,7 +5,7 @@ use abstutil::Timer;
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Circle, Distance, Line, PolyLine, Polygon};
use map_model::{
IntersectionType, Lane, LaneID, LaneType, Map, Road, Turn, LANE_THICKNESS, PARKING_SPOT_LENGTH,
IntersectionType, Lane, LaneID, LaneType, Map, Road, LANE_THICKNESS, PARKING_SPOT_LENGTH,
};
pub struct DrawLane {
@ -255,44 +255,33 @@ fn calculate_turn_markings(
{
return results;
}
for turn in map.get_turns_from_lane(lane.id) {
results.extend(turn_markings(turn, map, cs, timer));
if lane.length() < Distance::meters(7.0) {
return results;
}
results
}
fn turn_markings(
turn: &Turn,
map: &Map,
cs: &ColorScheme,
timer: &mut Timer,
) -> Vec<(Color, Polygon)> {
let lane = map.get_l(turn.id.src);
let len = lane.length();
if len < Distance::meters(7.0) {
return Vec::new();
}
let common_base = lane
.lane_center_pts
.exact_slice(len - Distance::meters(7.0), len - Distance::meters(5.0));
let base_polygon = common_base.make_polygons(Distance::meters(0.1));
let turn_line = PolyLine::new(vec![
common_base.last_pt(),
common_base
.last_pt()
.project_away(LANE_THICKNESS / 2.0, turn.angle()),
]);
let color = cs.get_def("turn restrictions on lane", Color::WHITE);
let mut result = vec![(color, base_polygon)];
result.extend(
turn_line
.make_arrow(Distance::meters(0.05))
let thickness = Distance::meters(0.2);
let common_base = lane.lane_center_pts.exact_slice(
lane.length() - Distance::meters(7.0),
lane.length() - Distance::meters(5.0),
);
results.push((color, common_base.make_polygons(thickness)));
// TODO Maybe draw arrows per target road, not lane
for turn in map.get_turns_from_lane(lane.id) {
results.extend(
PolyLine::new(vec![
common_base.last_pt(),
common_base
.last_pt()
.project_away(LANE_THICKNESS / 2.0, turn.angle()),
])
.make_arrow(thickness)
.with_context(timer, format!("turn_markings for {}", turn.id))
.into_iter()
.map(|p| (color, p)),
);
result
);
}
results
}

View File

@ -25,7 +25,6 @@ impl DrawPedestrian {
cs: &ColorScheme,
) -> DrawPedestrian {
let turn_arrow = if let Some(t) = input.waiting_for_turn {
// TODO this isn't quite right, but good enough for now
let angle = map.get_t(t).angle();
Some(
PolyLine::new(vec![

View File

@ -376,8 +376,9 @@ impl PolyLine {
// TODO One polygon, please :)
pub fn make_arrow(&self, thickness: Distance) -> Warn<Vec<Polygon>> {
// TODO Remove overlap between the triangle and last line segment
let head_size = thickness * 2.0;
// triangle_height is wrong. Sometimes there's overlap, sometimes there's a gap. But the
// trig seems so simple...
let triangle_height = (head_size / 2.0).sqrt();
if self.last_line().length() < triangle_height {
return Warn::warn(