mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 17:37:22 +03:00
dispersing the remainders of map_model::geometry
This commit is contained in:
parent
2c7e281a8e
commit
20a1bb7923
@ -3,7 +3,7 @@ use generator;
|
||||
use geo;
|
||||
use geo::prelude::Intersects;
|
||||
use geom::{Polygon, Pt2D};
|
||||
use map_model::{geometry, BuildingID, IntersectionID, LaneID, Map, ParcelID};
|
||||
use map_model::{BuildingID, IntersectionID, LaneID, Map, ParcelID};
|
||||
use piston::input::Key;
|
||||
use plugins::Colorizer;
|
||||
use render::DrawMap;
|
||||
@ -157,7 +157,7 @@ fn get_pt(map: &Map, id: ID) -> Pt2D {
|
||||
match id {
|
||||
ID::Lane(id) => map.get_l(id).first_pt(),
|
||||
ID::Intersection(id) => map.get_i(id).point,
|
||||
ID::Building(id) => geometry::center(&map.get_b(id).points),
|
||||
ID::Parcel(id) => geometry::center(&map.get_p(id).points),
|
||||
ID::Building(id) => Pt2D::center(&map.get_b(id).points),
|
||||
ID::Parcel(id) => Pt2D::center(&map.get_p(id).points),
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use ezgui::{Canvas, TextBox, UserInput};
|
||||
use map_model::{geometry, AreaID, BuildingID, IntersectionID, LaneID, Map, ParcelID, RoadID};
|
||||
use geom::Pt2D;
|
||||
use map_model::{AreaID, BuildingID, IntersectionID, LaneID, Map, ParcelID, RoadID};
|
||||
use objects::ID;
|
||||
use piston::input::Key;
|
||||
use plugins::Colorizer;
|
||||
@ -103,7 +104,7 @@ fn warp(line: String, map: &Map, sim: &Sim, canvas: &mut Canvas, selected: &mut
|
||||
if let Some(b) = map.maybe_get_b(id) {
|
||||
println!("Warping to {}", id);
|
||||
*selected = Some(ID::Building(id));
|
||||
geometry::center(&b.points)
|
||||
Pt2D::center(&b.points)
|
||||
} else {
|
||||
println!("{} doesn't exist", id);
|
||||
return;
|
||||
@ -114,7 +115,7 @@ fn warp(line: String, map: &Map, sim: &Sim, canvas: &mut Canvas, selected: &mut
|
||||
if let Some(a) = map.maybe_get_a(id) {
|
||||
println!("Warping to {}", id);
|
||||
*selected = Some(ID::Area(id));
|
||||
geometry::center(&a.points)
|
||||
Pt2D::center(&a.points)
|
||||
} else {
|
||||
println!("{} doesn't exist", id);
|
||||
return;
|
||||
@ -125,7 +126,7 @@ fn warp(line: String, map: &Map, sim: &Sim, canvas: &mut Canvas, selected: &mut
|
||||
let id = ParcelID(idx);
|
||||
if let Some(p) = map.maybe_get_p(id) {
|
||||
println!("Warping to {}", id);
|
||||
geometry::center(&p.points)
|
||||
Pt2D::center(&p.points)
|
||||
} else {
|
||||
println!("{} doesn't exist", id);
|
||||
return;
|
||||
|
@ -2,7 +2,7 @@ use colors::Colors;
|
||||
use dimensioned::si;
|
||||
use ezgui::GfxCtx;
|
||||
use geom::{Bounds, PolyLine, Polygon, Pt2D};
|
||||
use map_model::{geometry, BusStop, BusStopID, Map};
|
||||
use map_model::{BusStop, BusStopID, Map, LANE_THICKNESS};
|
||||
use objects::{Ctx, ID};
|
||||
use render::{RenderOptions, Renderable};
|
||||
|
||||
@ -27,7 +27,7 @@ impl DrawBusStop {
|
||||
lane.safe_dist_along(stop.dist_along + radius)
|
||||
.map(|(pt, _)| pt)
|
||||
.unwrap_or(lane.last_pt()),
|
||||
]).make_polygons_blindly(0.8 * geometry::LANE_THICKNESS);
|
||||
]).make_polygons_blindly(0.8 * LANE_THICKNESS);
|
||||
DrawBusStop {
|
||||
id: stop.id,
|
||||
polygon,
|
||||
|
@ -1,8 +1,8 @@
|
||||
use colors::Colors;
|
||||
use dimensioned::si;
|
||||
use ezgui::{shift_color, GfxCtx};
|
||||
use geom::{Bounds, Line, Polygon, Pt2D};
|
||||
use map_model::{geometry, Map};
|
||||
use geom::{Angle, Bounds, Line, PolyLine, Polygon, Pt2D};
|
||||
use map_model::Map;
|
||||
use objects::{Ctx, ID};
|
||||
use render::{RenderOptions, Renderable};
|
||||
use sim::{CarID, CarState, DrawCarInput};
|
||||
@ -48,7 +48,7 @@ impl DrawCar {
|
||||
DrawCar {
|
||||
id: input.id,
|
||||
turn_arrow,
|
||||
body_polygon: geometry::thick_line_from_angle(
|
||||
body_polygon: thick_line_from_angle(
|
||||
CAR_WIDTH,
|
||||
input.vehicle_length.value_unsafe,
|
||||
input.front,
|
||||
@ -58,7 +58,7 @@ impl DrawCar {
|
||||
// TODO it's way too hard to understand and tune this. just wait and stick in sprites
|
||||
// or something.
|
||||
window_polygons: vec![
|
||||
geometry::thick_line_from_angle(
|
||||
thick_line_from_angle(
|
||||
front_window_thickness,
|
||||
CAR_WIDTH - 2.0 * front_window_length_gap,
|
||||
input
|
||||
@ -70,7 +70,7 @@ impl DrawCar {
|
||||
),
|
||||
input.angle.rotate_degs(90.0),
|
||||
),
|
||||
geometry::thick_line_from_angle(
|
||||
thick_line_from_angle(
|
||||
front_window_thickness * 0.8,
|
||||
CAR_WIDTH - 2.0 * front_window_length_gap,
|
||||
input
|
||||
@ -132,3 +132,9 @@ impl Renderable for DrawCar {
|
||||
vec![self.id.to_string()]
|
||||
}
|
||||
}
|
||||
|
||||
fn thick_line_from_angle(thickness: f64, line_length: f64, pt: Pt2D, angle: Angle) -> Polygon {
|
||||
let pt2 = pt.project_away(line_length, angle);
|
||||
// Shouldn't ever fail for a single line
|
||||
PolyLine::new(vec![pt, pt2]).make_polygons_blindly(thickness)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use colors::Colors;
|
||||
use dimensioned::si;
|
||||
use ezgui::GfxCtx;
|
||||
use geom::{Bounds, Circle, Line, Polygon, Pt2D};
|
||||
use map_model::{geometry, Intersection, IntersectionID, LaneType, Map};
|
||||
use map_model::{Intersection, IntersectionID, LaneType, Map, LANE_THICKNESS};
|
||||
use objects::{Ctx, ID};
|
||||
use render::{DrawLane, RenderOptions, Renderable};
|
||||
use std::f64;
|
||||
@ -32,7 +32,7 @@ impl DrawIntersection {
|
||||
pts.push(line.pt2());
|
||||
}
|
||||
|
||||
let center = geometry::center(&pts);
|
||||
let center = Pt2D::center(&pts);
|
||||
// Sort points by angle from the center
|
||||
pts.sort_by_key(|pt| center.angle_to(*pt).normalized_degrees() as i64);
|
||||
let first_pt = pts[0].clone();
|
||||
@ -51,7 +51,7 @@ impl DrawIntersection {
|
||||
// TODO rotate it
|
||||
g.draw_polygon(
|
||||
ctx.cs.get(Colors::StopSignBackground),
|
||||
&geometry::regular_polygon(self.center, 8, 1.5),
|
||||
&Polygon::regular_polygon(self.center, 8, 1.5),
|
||||
);
|
||||
// TODO draw "STOP"
|
||||
}
|
||||
@ -170,13 +170,13 @@ fn calculate_crosswalks(inter: &Intersection, map: &Map) -> Vec<Vec<Line>> {
|
||||
// TODO awkward to express it this way
|
||||
|
||||
let mut markings = Vec::new();
|
||||
let tile_every = (geometry::LANE_THICKNESS * 0.6) * si::M;
|
||||
let tile_every = (LANE_THICKNESS * 0.6) * si::M;
|
||||
let mut dist_along = tile_every;
|
||||
while dist_along < length - tile_every {
|
||||
let pt1 = line.dist_along(dist_along);
|
||||
// Reuse perp_line. Project away an arbitrary amount
|
||||
let pt2 = pt1.project_away(1.0, angle);
|
||||
markings.push(perp_line(Line::new(pt1, pt2), geometry::LANE_THICKNESS));
|
||||
markings.push(perp_line(Line::new(pt1, pt2), LANE_THICKNESS));
|
||||
dist_along += tile_every;
|
||||
}
|
||||
crosswalks.push(markings);
|
||||
|
@ -6,9 +6,9 @@ use dimensioned::si;
|
||||
use ezgui::GfxCtx;
|
||||
use geom::{Bounds, Circle, Line, Polygon, Pt2D};
|
||||
use map_model;
|
||||
use map_model::{geometry, LaneID};
|
||||
use map_model::{LaneID, LANE_THICKNESS};
|
||||
use objects::{Ctx, ID};
|
||||
use render::{RenderOptions, Renderable, PARCEL_BOUNDARY_THICKNESS};
|
||||
use render::{RenderOptions, Renderable, BIG_ARROW_THICKNESS, PARCEL_BOUNDARY_THICKNESS};
|
||||
|
||||
const MIN_ZOOM_FOR_LANE_MARKERS: f64 = 5.0;
|
||||
|
||||
@ -35,18 +35,16 @@ pub struct DrawLane {
|
||||
impl DrawLane {
|
||||
pub fn new(lane: &map_model::Lane, map: &map_model::Map, control_map: &ControlMap) -> DrawLane {
|
||||
let road = map.get_r(lane.parent);
|
||||
let start = new_perp_line(lane.first_line(), geometry::LANE_THICKNESS);
|
||||
let end = new_perp_line(lane.last_line().reverse(), geometry::LANE_THICKNESS);
|
||||
let polygon = lane
|
||||
.lane_center_pts
|
||||
.make_polygons_blindly(geometry::LANE_THICKNESS);
|
||||
let start = new_perp_line(lane.first_line(), LANE_THICKNESS);
|
||||
let end = new_perp_line(lane.last_line().reverse(), LANE_THICKNESS);
|
||||
let polygon = lane.lane_center_pts.make_polygons_blindly(LANE_THICKNESS);
|
||||
|
||||
let mut markings: Vec<Marking> = Vec::new();
|
||||
if road.is_canonical_lane(lane.id) {
|
||||
markings.push(Marking {
|
||||
lines: road.center_pts.lines(),
|
||||
color: Colors::RoadOrientation,
|
||||
thickness: geometry::BIG_ARROW_THICKNESS,
|
||||
thickness: BIG_ARROW_THICKNESS,
|
||||
round: true,
|
||||
});
|
||||
}
|
||||
@ -193,7 +191,7 @@ fn new_perp_line(l: Line, length: f64) -> Line {
|
||||
}
|
||||
|
||||
fn calculate_sidewalk_lines(lane: &map_model::Lane) -> Marking {
|
||||
let tile_every = geometry::LANE_THICKNESS * si::M;
|
||||
let tile_every = LANE_THICKNESS * si::M;
|
||||
|
||||
let length = lane.length();
|
||||
|
||||
@ -204,7 +202,7 @@ fn calculate_sidewalk_lines(lane: &map_model::Lane) -> Marking {
|
||||
let (pt, angle) = lane.dist_along(dist_along);
|
||||
// Reuse perp_line. Project away an arbitrary amount
|
||||
let pt2 = pt.project_away(1.0, angle);
|
||||
lines.push(perp_line(Line::new(pt, pt2), geometry::LANE_THICKNESS));
|
||||
lines.push(perp_line(Line::new(pt, pt2), LANE_THICKNESS));
|
||||
dist_along += tile_every;
|
||||
}
|
||||
|
||||
@ -230,7 +228,7 @@ fn calculate_parking_lines(lane: &map_model::Lane) -> Marking {
|
||||
let perp_angle = lane_angle.rotate_degs(270.0);
|
||||
// Find the outside of the lane. Actually, shift inside a little bit, since the line will
|
||||
// have thickness, but shouldn't really intersect the adjacent line when drawn.
|
||||
let t_pt = pt.project_away(geometry::LANE_THICKNESS * 0.4, perp_angle);
|
||||
let t_pt = pt.project_away(LANE_THICKNESS * 0.4, perp_angle);
|
||||
// The perp leg
|
||||
let p1 = t_pt.project_away(leg_length, perp_angle.opposite());
|
||||
lines.push(Line::new(t_pt, p1));
|
||||
@ -259,7 +257,7 @@ fn calculate_driving_lines(lane: &map_model::Lane, parent: &map_model::Road) ->
|
||||
|
||||
// Project left, so reverse the points.
|
||||
let center_pts = lane.lane_center_pts.reversed();
|
||||
let lane_edge_pts = center_pts.shift_blindly(geometry::LANE_THICKNESS / 2.0);
|
||||
let lane_edge_pts = center_pts.shift_blindly(LANE_THICKNESS / 2.0);
|
||||
|
||||
// This is an incredibly expensive way to compute dashed polyines, and it doesn't follow bends
|
||||
// properly. Just a placeholder.
|
||||
@ -295,12 +293,11 @@ fn calculate_stop_sign_line(lane: &map_model::Lane, control_map: &ControlMap) ->
|
||||
|
||||
// TODO maybe draw the stop sign octagon on each lane?
|
||||
|
||||
let (pt1, angle) =
|
||||
lane.safe_dist_along(lane.length() - (2.0 * geometry::LANE_THICKNESS * si::M))?;
|
||||
let (pt1, angle) = lane.safe_dist_along(lane.length() - (2.0 * LANE_THICKNESS * si::M))?;
|
||||
// Reuse perp_line. Project away an arbitrary amount
|
||||
let pt2 = pt1.project_away(1.0, angle);
|
||||
Some(Marking {
|
||||
lines: vec![perp_line(Line::new(pt1, pt2), geometry::LANE_THICKNESS)],
|
||||
lines: vec![perp_line(Line::new(pt1, pt2), LANE_THICKNESS)],
|
||||
color: Colors::StopSignMarking,
|
||||
thickness: 0.45,
|
||||
round: true,
|
||||
@ -312,8 +309,7 @@ fn calculate_id_positions(lane: &map_model::Lane) -> Option<Vec<Pt2D>> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let (pt1, _) =
|
||||
lane.safe_dist_along(lane.length() - (2.0 * geometry::LANE_THICKNESS * si::M))?;
|
||||
let (pt2, _) = lane.safe_dist_along(2.0 * geometry::LANE_THICKNESS * si::M)?;
|
||||
let (pt1, _) = lane.safe_dist_along(lane.length() - (2.0 * LANE_THICKNESS * si::M))?;
|
||||
let (pt2, _) = lane.safe_dist_along(2.0 * LANE_THICKNESS * si::M)?;
|
||||
Some(vec![pt1, pt2])
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ mod turn;
|
||||
use ezgui::GfxCtx;
|
||||
use geom::{Bounds, Pt2D};
|
||||
use graphics::types::Color;
|
||||
use map_model::{geometry, Map};
|
||||
use map_model::Map;
|
||||
use objects::{Ctx, ID};
|
||||
pub use render::area::DrawArea;
|
||||
pub use render::car::DrawCar;
|
||||
@ -31,7 +31,8 @@ const BUILDING_BOUNDARY_THICKNESS: f64 = 1.5;
|
||||
const EXTRA_SHAPE_THICKNESS: f64 = 1.0;
|
||||
const EXTRA_SHAPE_POINT_RADIUS: f64 = 1.0;
|
||||
|
||||
const TURN_ICON_ARROW_THICKNESS: f64 = geometry::BIG_ARROW_THICKNESS / 3.0;
|
||||
pub const BIG_ARROW_THICKNESS: f64 = 0.5;
|
||||
const TURN_ICON_ARROW_THICKNESS: f64 = BIG_ARROW_THICKNESS / 3.0;
|
||||
const BIG_ARROW_TIP_LENGTH: f64 = 1.0;
|
||||
const TURN_ICON_ARROW_TIP_LENGTH: f64 = BIG_ARROW_TIP_LENGTH * 0.8;
|
||||
const TURN_ICON_ARROW_LENGTH: f64 = 2.0;
|
||||
|
@ -5,10 +5,10 @@ use dimensioned::si;
|
||||
use ezgui::GfxCtx;
|
||||
use geom::{Bounds, Circle, Line, Pt2D};
|
||||
use graphics::types::Color;
|
||||
use map_model::{geometry, Map, Turn, TurnID};
|
||||
use map_model::{Map, Turn, TurnID};
|
||||
use objects::{Ctx, ID};
|
||||
use render::{
|
||||
RenderOptions, Renderable, BIG_ARROW_TIP_LENGTH, TURN_ICON_ARROW_LENGTH,
|
||||
RenderOptions, Renderable, BIG_ARROW_THICKNESS, BIG_ARROW_TIP_LENGTH, TURN_ICON_ARROW_LENGTH,
|
||||
TURN_ICON_ARROW_THICKNESS, TURN_ICON_ARROW_TIP_LENGTH,
|
||||
};
|
||||
use std::f64;
|
||||
@ -53,7 +53,7 @@ impl DrawTurn {
|
||||
pub fn draw_full(&self, g: &mut GfxCtx, color: Color) {
|
||||
g.draw_rounded_arrow(
|
||||
color,
|
||||
geometry::BIG_ARROW_THICKNESS,
|
||||
BIG_ARROW_THICKNESS,
|
||||
BIG_ARROW_TIP_LENGTH,
|
||||
&Line::new(self.src_pt, self.dst_pt),
|
||||
);
|
||||
|
@ -1,4 +1,5 @@
|
||||
use graphics::math::Vec2d;
|
||||
use std::f64;
|
||||
use {Bounds, Pt2D};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -108,6 +109,20 @@ impl Polygon {
|
||||
}
|
||||
b
|
||||
}
|
||||
|
||||
pub fn regular_polygon(center: Pt2D, sides: usize, length: f64) -> Polygon {
|
||||
let mut pts = Vec::new();
|
||||
for i in 0..sides {
|
||||
let theta = (i as f64) * 2.0 * f64::consts::PI / (sides as f64);
|
||||
pts.push(Pt2D::new(
|
||||
length * theta.cos() + center.x(),
|
||||
length * theta.sin() + center.y(),
|
||||
));
|
||||
}
|
||||
let first_pt = pts[0];
|
||||
pts.push(first_pt);
|
||||
Polygon::new(&pts)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -71,6 +71,17 @@ impl Pt2D {
|
||||
pub fn offset(&self, dx: f64, dy: f64) -> Pt2D {
|
||||
Pt2D::new(self.x() + dx, self.y() + dy)
|
||||
}
|
||||
|
||||
pub fn center(pts: &Vec<Pt2D>) -> Pt2D {
|
||||
let mut x = 0.0;
|
||||
let mut y = 0.0;
|
||||
for pt in pts {
|
||||
x += pt.x();
|
||||
y += pt.y();
|
||||
}
|
||||
let len = pts.len() as f64;
|
||||
Pt2D::new(x / len, y / len)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Pt2D {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use abstutil;
|
||||
use geom::{PolyLine, Polygon, Pt2D};
|
||||
use geometry::LANE_THICKNESS;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use LANE_THICKNESS;
|
||||
|
||||
// TODO reconsider pub usize. maybe outside world shouldnt know.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
|
@ -1,38 +0,0 @@
|
||||
// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
use geom::{Angle, PolyLine, Polygon, Pt2D};
|
||||
use std::f64;
|
||||
|
||||
pub const LANE_THICKNESS: f64 = 2.5;
|
||||
pub const BIG_ARROW_THICKNESS: f64 = 0.5;
|
||||
|
||||
pub fn thick_line_from_angle(thickness: f64, line_length: f64, pt: Pt2D, angle: Angle) -> Polygon {
|
||||
let pt2 = pt.project_away(line_length, angle);
|
||||
// Shouldn't ever fail for a single line
|
||||
PolyLine::new(vec![pt, pt2]).make_polygons_blindly(thickness)
|
||||
}
|
||||
|
||||
pub fn center(pts: &Vec<Pt2D>) -> Pt2D {
|
||||
let mut x = 0.0;
|
||||
let mut y = 0.0;
|
||||
for pt in pts {
|
||||
x += pt.x();
|
||||
y += pt.y();
|
||||
}
|
||||
let len = pts.len() as f64;
|
||||
Pt2D::new(x / len, y / len)
|
||||
}
|
||||
|
||||
pub fn regular_polygon(center: Pt2D, sides: usize, length: f64) -> Polygon {
|
||||
let mut pts = Vec::new();
|
||||
for i in 0..sides {
|
||||
let theta = (i as f64) * 2.0 * f64::consts::PI / (sides as f64);
|
||||
pts.push(Pt2D::new(
|
||||
length * theta.cos() + center.x(),
|
||||
length * theta.sin() + center.y(),
|
||||
));
|
||||
}
|
||||
let first_pt = pts[0];
|
||||
pts.push(first_pt);
|
||||
Polygon::new(&pts)
|
||||
}
|
@ -16,7 +16,6 @@ mod area;
|
||||
mod building;
|
||||
mod bus_stop;
|
||||
mod edits;
|
||||
pub mod geometry;
|
||||
mod intersection;
|
||||
mod lane;
|
||||
mod make;
|
||||
@ -38,3 +37,5 @@ pub use parcel::{Parcel, ParcelID};
|
||||
pub use pathfind::Pathfinder;
|
||||
pub use road::{Road, RoadID};
|
||||
pub use turn::{Turn, TurnID};
|
||||
|
||||
pub const LANE_THICKNESS: f64 = 2.5;
|
||||
|
@ -1,6 +1,5 @@
|
||||
use dimensioned::si;
|
||||
use geom::{Bounds, HashablePt2D, Line, PolyLine, Pt2D};
|
||||
use geometry;
|
||||
use make::sidewalk_finder::find_sidewalk_points;
|
||||
use raw_data;
|
||||
use std::collections::HashSet;
|
||||
@ -21,7 +20,7 @@ pub(crate) fn make_all_buildings(
|
||||
.iter()
|
||||
.map(|coord| Pt2D::from_gps(coord, bounds))
|
||||
.collect();
|
||||
let center: HashablePt2D = geometry::center(&pts).into();
|
||||
let center: HashablePt2D = Pt2D::center(&pts).into();
|
||||
pts_per_bldg.push(pts);
|
||||
center_per_bldg.push(center);
|
||||
query.insert(center);
|
||||
|
@ -1,6 +1,5 @@
|
||||
use dimensioned::si;
|
||||
use geom::{Bounds, HashablePt2D, Line, Pt2D};
|
||||
use geometry;
|
||||
use make::sidewalk_finder::find_sidewalk_points;
|
||||
use raw_data;
|
||||
use std::collections::HashSet;
|
||||
@ -21,7 +20,7 @@ pub(crate) fn make_all_parcels(
|
||||
.iter()
|
||||
.map(|coord| Pt2D::from_gps(coord, bounds))
|
||||
.collect();
|
||||
let center: HashablePt2D = geometry::center(&pts).into();
|
||||
let center: HashablePt2D = Pt2D::center(&pts).into();
|
||||
pts_per_parcel.push(pts);
|
||||
center_per_parcel.push(center);
|
||||
query.insert(center);
|
||||
|
@ -4,7 +4,6 @@ use abstutil;
|
||||
use edits::Edits;
|
||||
use flame;
|
||||
use geom::{Bounds, HashablePt2D, PolyLine, Pt2D};
|
||||
use geometry;
|
||||
use make;
|
||||
use raw_data;
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
@ -12,7 +11,7 @@ use std::io::Error;
|
||||
use std::path;
|
||||
use {
|
||||
Area, AreaID, Building, BuildingID, BusRoute, BusStop, BusStopID, Intersection, IntersectionID,
|
||||
Lane, LaneID, LaneType, Parcel, ParcelID, Road, RoadID, Turn, TurnID,
|
||||
Lane, LaneID, LaneType, Parcel, ParcelID, Road, RoadID, Turn, TurnID, LANE_THICKNESS,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
@ -124,7 +123,7 @@ impl Map {
|
||||
// TODO probably different behavior for oneways
|
||||
// TODO need to factor in yellow center lines (but what's the right thing to even do?
|
||||
// Reverse points for British-style driving on the left
|
||||
let width = geometry::LANE_THICKNESS * ((lane.offset as f64) + 0.5);
|
||||
let width = LANE_THICKNESS * ((lane.offset as f64) + 0.5);
|
||||
let (lane_center_pts, probably_broken) = match unshifted_pts.shift(width) {
|
||||
Some(pts) => (pts, false),
|
||||
// TODO wasteful to calculate again, but eh
|
||||
|
@ -7,7 +7,7 @@ extern crate piston;
|
||||
use ezgui::{Canvas, EventLoopMode, GfxCtx, UserInput, GUI};
|
||||
use geom::{Circle, PolyLine, Polygon, Pt2D};
|
||||
use graphics::types::Color;
|
||||
use map_model::geometry;
|
||||
use map_model::LANE_THICKNESS;
|
||||
use piston::input::Key;
|
||||
use piston::window::Size;
|
||||
use std::f64;
|
||||
@ -228,8 +228,8 @@ impl UI {
|
||||
|
||||
fn debug_intersection(&self, g: &mut GfxCtx, _labels: &mut Vec<(Pt2D, String)>) {
|
||||
let thin = 0.25;
|
||||
let shift1_width = geometry::LANE_THICKNESS * 0.5;
|
||||
let shift2_width = geometry::LANE_THICKNESS * 1.5;
|
||||
let shift1_width = LANE_THICKNESS * 0.5;
|
||||
let shift2_width = LANE_THICKNESS * 1.5;
|
||||
|
||||
// All the center lines are expressed as incoming to the intersection
|
||||
let shared_pt = Pt2D::new(1983.3524141911557, 1260.9463599480669);
|
||||
@ -324,7 +324,7 @@ fn draw_polyline(g: &mut GfxCtx, pl: &PolyLine, thickness: f64, color: Color) {
|
||||
}
|
||||
|
||||
fn draw_lane(g: &mut GfxCtx, pl: &PolyLine, color: Color) {
|
||||
g.draw_polygon(color, &pl.make_polygons(geometry::LANE_THICKNESS).unwrap());
|
||||
g.draw_polygon(color, &pl.make_polygons(LANE_THICKNESS).unwrap());
|
||||
|
||||
// Debug the center points
|
||||
draw_polyline(g, pl, 0.25, SOLID_BLACK);
|
||||
|
@ -6,8 +6,7 @@ use geom::EPSILON_DIST;
|
||||
use intersections::{IntersectionSimState, Request};
|
||||
use kinematics;
|
||||
use kinematics::Vehicle;
|
||||
use map_model::geometry::LANE_THICKNESS;
|
||||
use map_model::{LaneID, Map, TurnID};
|
||||
use map_model::{LaneID, Map, TurnID, LANE_THICKNESS};
|
||||
use multimap::MultiMap;
|
||||
use ordered_float::NotNaN;
|
||||
use parking::ParkingSimState;
|
||||
|
Loading…
Reference in New Issue
Block a user