Simplify some lane lookups that just needed to find the parent

This commit is contained in:
Dustin Carlino 2021-09-05 18:05:49 -07:00
parent 112bc38e0c
commit 442523ae6c
33 changed files with 81 additions and 94 deletions

View File

@ -87,7 +87,7 @@ impl Isochrone {
}
_ => {}
}
all_roads.insert(app.map.get_l(bldg.sidewalk_pos.lane()).parent);
all_roads.insert(bldg.sidewalk_pos.lane().road);
}
let mut onstreet_parking_spots = 0;

View File

@ -109,7 +109,7 @@ impl RoadSelector {
app.primary.current_selection =
match app.mouseover_unzoomed_roads_and_intersections(ctx) {
Some(ID::Road(r)) => Some(r),
Some(ID::Lane(l)) => Some(app.primary.map.get_l(l).parent),
Some(ID::Lane(l)) => Some(l.road),
_ => None,
}
.and_then(|r| {

View File

@ -771,11 +771,9 @@ impl ContextualActions for Actions {
mode.reset_info(ctx);
}))
}
(ID::Lane(l), "export roads") => Transition::Push(select_roads::BulkSelect::new_state(
ctx,
app,
app.primary.map.get_l(l).parent,
)),
(ID::Lane(l), "export roads") => {
Transition::Push(select_roads::BulkSelect::new_state(ctx, app, l.road))
}
(ID::Lane(l), "show equiv_pos") => {
Transition::ModifyState(Box::new(move |state, ctx, app| {
if let Some(pt) = ctx.canvas.get_cursor_in_map_space() {
@ -1022,12 +1020,12 @@ fn draw_banned_turns(ctx: &mut EventCtx, app: &App) -> Drawable {
// Don't call out one-ways, so use incoming/outgoing roads, and just for cars.
for l1 in i.get_incoming_lanes(map, PathConstraints::Car) {
for l2 in i.get_outgoing_lanes(map, PathConstraints::Car) {
pairs.insert((map.get_l(l1).parent, map.get_l(l2).parent));
pairs.insert((l1.road, l2.road));
}
}
for t in &i.turns {
let r1 = map.get_l(t.id.src).parent;
let r2 = map.get_l(t.id.dst).parent;
let r1 = t.id.src.road;
let r2 = t.id.dst.road;
pairs.remove(&(r1, r2));
}

View File

@ -39,7 +39,7 @@ impl PathCounter {
// Count what lanes they'll cross
for step in path.get_steps() {
if let Traversable::Lane(l) = step.as_traversable() {
cnt.inc(map.get_l(l).parent);
cnt.inc(l.road);
}
}
}
@ -89,7 +89,7 @@ impl State<App> for PathCounter {
app.primary.current_selection = app.mouseover_unzoomed_roads_and_intersections(ctx);
self.tooltip = None;
if let Some(r) = match app.primary.current_selection {
Some(ID::Lane(l)) => Some(app.primary.map.get_l(l).parent),
Some(ID::Lane(l)) => Some(l.road),
Some(ID::Road(r)) => Some(r),
_ => None,
} {

View File

@ -489,7 +489,7 @@ fn calculate_demand(app: &App, requests: &[PathRequest], timer: &mut Timer) -> C
timer.next();
for step in path.get_steps() {
if let Traversable::Lane(l) = step.as_traversable() {
counter.inc(app.primary.map.get_l(l).parent);
counter.inc(l.road);
}
}
}

View File

@ -211,7 +211,7 @@ impl State<App> for SelectSegments {
ctx.show_cursor();
if let Some(r) = match app.mouseover_unzoomed_roads_and_intersections(ctx) {
Some(ID::Road(r)) => Some(r),
Some(ID::Lane(l)) => Some(app.primary.map.get_l(l).parent),
Some(ID::Lane(l)) => Some(l.road),
_ => None,
} {
if self.candidates.contains(&r) {

View File

@ -42,7 +42,7 @@ pub struct RoadEditor {
impl RoadEditor {
/// Always starts focused on a certain lane.
pub fn new_state(ctx: &mut EventCtx, app: &mut App, l: LaneID) -> Box<dyn State<App>> {
RoadEditor::create(ctx, app, app.primary.map.get_l(l).parent, Some(l))
RoadEditor::create(ctx, app, l.road, Some(l))
}
pub fn new_state_without_lane(
@ -442,7 +442,7 @@ impl State<App> for RoadEditor {
}
if let Some(l) = self.hovering_on_lane {
if ctx.normal_left_click() {
if app.primary.map.get_l(l).parent == self.r {
if l.road == self.r {
self.selected_lane = Some(l);
panels_need_recalc = true;
} else {
@ -966,8 +966,10 @@ fn lane_type_to_icon(lt: LaneType) -> Option<&'static str> {
fn width_choices(app: &App, l: LaneID) -> Vec<Choice<Distance>> {
let lane = app.primary.map.get_l(l);
let mut choices =
LaneSpec::typical_lane_widths(lane.lane_type, &app.primary.map.get_r(lane.parent).osm_tags);
let mut choices = LaneSpec::typical_lane_widths(
lane.lane_type,
&app.primary.map.get_r(lane.id.road).osm_tags,
);
if !choices.iter().any(|(x, _)| *x == lane.width) {
choices.push((lane.width, "custom"));
}

View File

@ -19,7 +19,7 @@ fn info_body(ctx: &EventCtx, app: &App, id: LaneID) -> Widget {
let map = &app.primary.map;
let l = map.get_l(id);
let r = map.get_r(l.parent);
let r = map.get_r(id.road);
let mut kv = Vec::new();
@ -114,7 +114,7 @@ fn debug_body(ctx: &EventCtx, app: &App, id: LaneID) -> Widget {
let map = &app.primary.map;
let l = map.get_l(id);
let r = map.get_r(l.parent);
let r = map.get_r(id.road);
let mut kv = vec![("Parent".to_string(), r.id.to_string())];
@ -215,21 +215,18 @@ pub fn traffic(
fn traffic_body(ctx: &mut EventCtx, app: &App, id: LaneID, opts: &DataOptions) -> Widget {
let mut rows = vec![];
let map = &app.primary.map;
let l = map.get_l(id);
let r = map.get_r(l.parent);
let r = id.road;
// Since this applies to the entire road, ignore lane type.
let mut txt = Text::from("Traffic over entire road, not just this lane");
txt.add_line(format!(
"Since midnight: {} commuters and vehicles crossed",
prettyprint_usize(app.primary.sim.get_analytics().road_thruput.total_for(r.id))
prettyprint_usize(app.primary.sim.get_analytics().road_thruput.total_for(r))
));
rows.push(txt.into_widget(ctx));
rows.push(opts.to_controls(ctx, app));
let r = map.get_l(id).parent;
let time = if opts.show_end_of_day {
app.primary.sim.get_end_of_day()
} else {
@ -258,7 +255,7 @@ fn header(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID, tab: Tab
let map = &app.primary.map;
let l = map.get_l(id);
let r = map.get_r(l.parent);
let r = map.get_r(id.road);
let label = if l.is_shoulder() {
"Shoulder"

View File

@ -79,7 +79,7 @@ impl BikeActivity {
// Make sure all bikes lanes show up no matter what
for l in app.primary.map.all_lanes() {
if l.is_biking() {
on_bike_lanes.add(l.parent, 0);
on_bike_lanes.add(l.id.road, 0);
intersections_on.add(l.src_i, 0);
intersections_on.add(l.src_i, 0);
num_lanes += 1;
@ -300,8 +300,8 @@ impl Static {
pub fn no_sidewalks(ctx: &mut EventCtx, app: &App) -> Static {
let mut colorer = ColorDiscrete::new(app, vec![("no sidewalks", Color::RED)]);
for l in app.primary.map.all_lanes() {
if l.is_shoulder() && !app.primary.map.get_r(l.parent).is_cycleway() {
colorer.add_r(l.parent, "no sidewalks");
if l.is_shoulder() && !app.primary.map.get_parent(l.id).is_cycleway() {
colorer.add_r(l.id.road, "no sidewalks");
}
}
Static::new(

View File

@ -4,7 +4,7 @@ use abstutil::{prettyprint_usize, Counter};
use geom::{Circle, Distance, Duration, Pt2D, Time};
use map_gui::render::unzoomed_agent_radius;
use map_gui::tools::{ColorLegend, ColorNetwork};
use map_model::{BuildingID, Map, OffstreetParking, ParkingLotID, PathRequest, RoadID};
use map_model::{BuildingID, OffstreetParking, ParkingLotID, PathRequest, RoadID};
use sim::{ParkingSpot, VehicleType};
use widgetry::{Drawable, EventCtx, GeomBatch, GfxCtx, Line, Outcome, Panel, Text, Toggle, Widget};
@ -186,7 +186,7 @@ impl Occupancy {
}
}
let loc = Loc::new(spot, &app.primary.map);
let loc = Loc::new(spot);
keys.insert(loc);
spots.inc(loc);
}
@ -290,9 +290,9 @@ enum Loc {
}
impl Loc {
fn new(spot: ParkingSpot, map: &Map) -> Loc {
fn new(spot: ParkingSpot) -> Loc {
match spot {
ParkingSpot::Onstreet(l, _) => Loc::Road(map.get_l(l).parent),
ParkingSpot::Onstreet(l, _) => Loc::Road(l.road),
ParkingSpot::Offstreet(b, _) => Loc::Bldg(b),
ParkingSpot::Lot(pl, _) => Loc::Lot(pl),
}

View File

@ -56,7 +56,7 @@ impl Backpressure {
for step in path.get_steps() {
match step.as_traversable() {
Traversable::Lane(l) => {
cnt_per_r.inc(app.primary.map.get_l(l).parent);
cnt_per_r.inc(l.road);
}
Traversable::Turn(t) => {
cnt_per_i.inc(t.parent);

View File

@ -636,7 +636,7 @@ fn partition_sidewalk_loops(app: &App) -> Vec<Loop> {
groups.push(Loop {
bldgs,
proper: true,
roads: sidewalks.into_iter().map(|l| map.get_l(l).parent).collect(),
roads: sidewalks.into_iter().map(|l| l.road).collect(),
});
} else {
remainder.extend(bldgs);
@ -684,9 +684,7 @@ fn partition_sidewalk_loops(app: &App) -> Vec<Loop> {
per_sidewalk.insert(map.get_b(b).sidewalk(), b);
}
for (_, bldgs) in per_sidewalk.consume() {
let r = map
.get_l(map.get_b(*bldgs.iter().next().unwrap()).sidewalk())
.parent;
let r = map.get_b(*bldgs.iter().next().unwrap()).sidewalk().road;
groups.push(Loop {
bldgs: bldgs.into_iter().collect(),
proper: false,

View File

@ -80,7 +80,7 @@ impl State<App> for ExploreMap {
app.primary.current_selection =
match app.mouseover_unzoomed_roads_and_intersections(ctx) {
Some(ID::Road(r)) => Some(r),
Some(ID::Lane(l)) => Some(app.primary.map.get_l(l).parent),
Some(ID::Lane(l)) => Some(l.road),
_ => None,
}
.and_then(|r| {

View File

@ -169,8 +169,8 @@ impl RouteResults {
num_traffic_signals += 1;
}
if map.is_unprotected_turn(
map.get_l(t.src).parent,
map.get_l(t.dst).parent,
t.src.road,
t.dst.road,
map.get_t(*t).turn_type,
) {
num_unprotected_turns += 1;

View File

@ -74,7 +74,10 @@ fn generate_buildings_on_empty_residential_roads(
for l in map.all_lanes() {
if l.is_sidewalk()
&& !lanes_with_buildings.contains(&l.id)
&& map.get_r(l.parent).osm_tags.is(osm::HIGHWAY, "residential")
&& map
.get_parent(l.id)
.osm_tags
.is(osm::HIGHWAY, "residential")
{
empty_sidewalks.push(l.id);
}

View File

@ -23,7 +23,7 @@ impl DrawLane {
DrawLane {
id: lane.id,
polygon: lane.lane_center_pts.make_polygons(lane.width),
zorder: map.get_r(lane.parent).zorder,
zorder: map.get_r(lane.id.road).zorder,
draw_default: RefCell::new(None),
}
}
@ -31,7 +31,7 @@ impl DrawLane {
pub fn render<P: AsRef<Prerender>>(&self, prerender: &P, app: &dyn AppLike) -> GeomBatch {
let map = app.map();
let lane = map.get_l(self.id);
let road = map.get_r(lane.parent);
let road = map.get_r(lane.id.road);
let rank = road.get_rank();
let mut batch = GeomBatch::new();
@ -316,7 +316,7 @@ fn calculate_turn_markings(map: &Map, lane: &Lane) -> Vec<Polygon> {
if i.outgoing_lanes.iter().all(|l| {
let l = map.get_l(*l);
l.lane_type != lane.lane_type
|| l.parent == lane.parent
|| l.id.road == lane.id.road
|| map
.maybe_get_t(TurnID {
parent: i.id,
@ -333,7 +333,7 @@ fn calculate_turn_markings(map: &Map, lane: &Lane) -> Vec<Polygon> {
let mut angles_per_road: HashMap<RoadID, Vec<Angle>> = HashMap::new();
for turn in map.get_turns_from_lane(lane.id) {
angles_per_road
.entry(map.get_l(turn.id.dst).parent)
.entry(turn.id.dst.road)
.or_insert_with(Vec::new)
.push(turn.angle());
}

View File

@ -706,9 +706,7 @@ fn fix_building_driveways(map: &mut Map, input: Vec<BuildingID>, effects: &mut E
b.sidewalk_pos = sidewalk_pos;
b.driveway_geom = driveway_geom.to_polyline();
// We may need to redraw the road that now has this building snapped to it
effects
.changed_roads
.insert(map.get_l(sidewalk_pos.lane()).parent);
effects.changed_roads.insert(sidewalk_pos.lane().road);
}
None => {
// TODO Not sure what to do here yet.

View File

@ -41,7 +41,7 @@ pub fn make_all_turns(map: &Map, i: &Intersection) -> Vec<Turn> {
// U-turns at divided highways are sometimes legal (and a common movement --
// https://www.openstreetmap.org/way/361443212), so let OSM turn:lanes override.
if src_lane
.get_lane_level_turn_restrictions(map.get_r(src_lane.parent), false)
.get_lane_level_turn_restrictions(map.get_r(src_lane.id.road), false)
.map(|set| !set.contains(&TurnType::UTurn))
.unwrap_or(true)
{
@ -153,7 +153,7 @@ fn make_vehicle_turns(i: &Intersection, map: &Map) -> Vec<Turn> {
continue;
}
// Only allow U-turns at deadends
if src.parent == dst.parent && !is_deadend {
if src.id.road == dst.id.road && !is_deadend {
continue;
}
// Can't go between light rail and normal roads
@ -192,14 +192,14 @@ fn make_vehicle_turns(i: &Intersection, map: &Map) -> Vec<Turn> {
}
} else if let Some(expected_type) = expected_turn_types
.as_ref()
.and_then(|e| e.get(&(src.parent, dst.parent)))
.and_then(|e| e.get(&(src.id.road, dst.id.road)))
{
// At some 4-way intersections, roads meet at strange angles, throwing off
// turn_type_from_angles. Correct it based on relative ordering.
if turn_type != *expected_type {
warn!(
"Turn from {} to {} looks like {:?} by angle, but is {:?} by ordering",
src.parent, dst.parent, turn_type, expected_type
src.id.road, dst.id.road, turn_type, expected_type
);
turn_type = *expected_type;
}
@ -290,7 +290,7 @@ fn remove_merging_turns(map: &Map, input: Vec<Turn>, turn_type: TurnType) -> Vec
if t.turn_type == turn_type {
pairs
.entry((map.get_l(t.id.src).parent, map.get_l(t.id.dst).parent))
.entry((t.id.src.road, t.id.dst.road))
.or_insert_with(Vec::new)
.push(t);
} else {

View File

@ -177,9 +177,7 @@ pub fn filter_turns(mut input: Vec<Turn>, map: &Map, i: &Intersection) -> Vec<Tu
for r in &i.roads {
if map.get_r(*r).is_extremely_short() {
input.retain(|t| {
!(map.get_l(t.id.src).parent == *r
&& map.get_l(t.id.dst).parent == *r
&& t.turn_type == TurnType::Crosswalk)
!(t.id.src.road == *r && t.id.dst.road == *r && t.turn_type == TurnType::Crosswalk)
});
}
}
@ -271,7 +269,7 @@ fn make_walking_turns_v2(map: &Map, i: &Intersection) -> Vec<Turn> {
}
let l2 = l.unwrap();
if adj && l1.parent != l2.parent {
if adj && l1.id.road != l2.id.road {
// Because of the order we go, have to swap l1 and l2 here. l1 is the outgoing, l2 the
// incoming.
let geom = make_shared_sidewalk_corner(driving_side, i, l2, l1);

View File

@ -431,8 +431,7 @@ impl Map {
}
pub fn get_parent(&self, id: LaneID) -> &Road {
let l = self.get_l(id);
self.get_r(l.parent)
self.get_r(id.road)
}
pub fn get_gps_bounds(&self) -> &GPSBounds {
@ -773,7 +772,7 @@ impl Map {
pub(crate) fn recalculate_road_to_buildings(&mut self) {
let mut mapping = MultiMap::new();
for b in self.all_buildings() {
mapping.insert(self.get_l(b.sidewalk_pos.lane()).parent, b.id);
mapping.insert(b.sidewalk_pos.lane().road, b.id);
}
self.road_to_buildings = mapping;
}

View File

@ -239,7 +239,6 @@ impl LaneType {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Lane {
pub id: LaneID,
pub parent: RoadID,
pub lane_type: LaneType,
pub lane_center_pts: PolyLine,
pub width: Distance,
@ -362,7 +361,7 @@ impl Lane {
pub fn get_directed_parent(&self) -> DirectedRoadID {
DirectedRoadID {
id: self.parent,
id: self.id.road,
dir: self.dir,
}
}
@ -478,7 +477,7 @@ impl Lane {
//println!("{}, fwd={}, pointing to {}", current, fwd, i);
let mut roads = map.get_i(i).get_roads_sorted_by_incoming_angle(map);
roads.retain(|r| !map.get_r(*r).is_footway());
let idx = roads.iter().position(|r| *r == l.parent).unwrap();
let idx = roads.iter().position(|r| *r == l.id.road).unwrap();
// Get the next road counter-clockwise
let next_road = map.get_r(*wraparound_get(&roads, (idx as isize) + 1));
// Depending on if this road points to or from the intersection, get the left- or

View File

@ -545,7 +545,6 @@ impl Road {
dst_i,
lane_type: lane.lt,
dir: lane.dir,
parent: self.id,
bus_stops: BTreeSet::new(),
driving_blackhole: false,
biking_blackhole: false,

View File

@ -162,7 +162,7 @@ impl ControlStopSign {
// TODO This actually feels like a policy bit that should be flippable.
TurnType::Crosswalk => TurnPriority::Protected,
_ => {
if self.roads[&map.get_l(turn.src).parent].must_stop {
if self.roads[&turn.src.road].must_stop {
TurnPriority::Yield
} else {
TurnPriority::Protected

View File

@ -115,7 +115,7 @@ impl Turn {
// lane? Filters by the lane type and ignores lanes that don't go to the target road.
let from_idx = {
let mut cnt = 0;
let r = map.get_r(from.parent);
let r = map.get_r(from.id.road);
for (l, lt) in r.children(from.dir).iter().rev() {
if from.lane_type != *lt {
continue;
@ -123,7 +123,7 @@ impl Turn {
if map
.get_turns_from_lane(*l)
.into_iter()
.any(|t| map.get_l(t.id.dst).parent == to.parent)
.any(|t| t.id.dst.road == to.id.road)
{
cnt += 1;
if from.id == *l {
@ -138,7 +138,7 @@ impl Turn {
// lane? Filters by the lane type.
let to_idx = {
let mut cnt = 0;
let r = map.get_r(to.parent);
let r = map.get_r(to.id.road);
for (l, lt) in r.children(to.dir).iter().rev() {
if to.lane_type != *lt {
continue;
@ -220,7 +220,7 @@ impl Turn {
}
let src = map.get_parent(self.id.src);
let dst = map.get_l(self.id.dst).parent;
let dst = self.id.dst.road;
for (restriction, to) in &src.turn_restrictions {
// The restriction only applies to one direction of the road.

View File

@ -70,7 +70,7 @@ impl PathConstraints {
true
} else if lane.is_driving() || (lane.is_bus() && map.config.bikes_can_use_bus_lanes)
{
let road = map.get_r(lane.parent);
let road = map.get_r(lane.id.road);
!road.osm_tags.is("bicycle", "no")
&& !road
.osm_tags
@ -102,7 +102,8 @@ impl PathConstraints {
// practice this isn't an issue; a bus lane often leads to another one, but the next bus
// lane won't also be an exclusive turn lane.
if lane.is_bus() {
if let Some(types) = lane.get_lane_level_turn_restrictions(map.get_r(lane.parent), true)
if let Some(types) =
lane.get_lane_level_turn_restrictions(map.get_r(lane.id.road), true)
{
if types.contains(&TurnType::Right) || types.contains(&TurnType::Left) {
return true;

View File

@ -125,9 +125,9 @@ impl IntersectionCluster {
uber_turns.retain(|ut| {
let mut ok = true;
for pair in ut.path.windows(2) {
let r1 = map.get_l(pair[0].src).parent;
let r2 = map.get_l(pair[0].dst).parent;
let r3 = map.get_l(pair[1].dst).parent;
let r1 = pair[0].src.road;
let r2 = pair[0].dst.road;
let r3 = pair[1].dst.road;
if all_restrictions.contains(&(r1, r2, r3)) {
ok = false;
break;

View File

@ -616,10 +616,10 @@ impl PathRequest {
) -> PathRequest {
let alt_start = (|| {
let start_lane = map.get_l(start.lane());
let road = map.get_r(start_lane.parent);
let road = map.get_r(start_lane.id.road);
// If start and end road match, don't exit offside
// TODO Sometimes this is valid! Just not if we're trying to go behind ourselves
if road.id == map.get_l(end.lane()).parent {
if road.id == end.lane().road {
return None;
}
let offside_dir = start_lane.dir.opposite();
@ -692,8 +692,8 @@ fn validate_restrictions(map: &Map, steps: &[PathStep]) {
(triple[0], triple[2], triple[4])
{
let from = map.get_parent(l1);
let via = map.get_l(l2).parent;
let to = map.get_l(l3).parent;
let via = l2.road;
let to = l3.road;
for (dont_via, dont_to) in &from.complicated_turn_restrictions {
if via == *dont_via && to == *dont_to {

View File

@ -82,7 +82,7 @@ impl Position {
) -> Position {
let our_lane = map.get_l(self.lane);
let other_lane = map.get_l(other_lane);
assert_eq!(our_lane.parent, other_lane.parent);
assert_eq!(our_lane.id.road, other_lane.id.road);
let pl = &other_lane.lane_center_pts;
let pt = self.pt(map);

View File

@ -194,7 +194,7 @@ impl State<App> for ParkingMapper {
if ctx.redo_mouseover() {
let mut maybe_r = match app.mouseover_unzoomed_roads_and_intersections(ctx) {
Some(ID::Road(r)) => Some(r),
Some(ID::Lane(l)) => Some(map.get_l(l).parent),
Some(ID::Lane(l)) => Some(l.road),
_ => None,
};
if let Some(r) = maybe_r {

View File

@ -107,15 +107,10 @@ impl Analytics {
if let Event::AgentEntersTraversable(a, _, to, passengers) = ev {
match to {
Traversable::Lane(l) => {
self.road_thruput
.record(time, map.get_l(l).parent, a.to_type(), 1);
self.road_thruput.record(time, l.road, a.to_type(), 1);
if let Some(n) = passengers {
self.road_thruput.record(
time,
map.get_l(l).parent,
AgentType::TransitRider,
n,
);
self.road_thruput
.record(time, l.road, AgentType::TransitRider, n);
}
}
Traversable::Turn(t) => {

View File

@ -378,7 +378,7 @@ impl DrivingGoal {
PathConstraints::Car => {
let driving_lane = map.find_driving_lane_near_building(*b);
let sidewalk_pos = map.get_b(*b).sidewalk_pos;
if map.get_l(driving_lane).parent == map.get_l(sidewalk_pos.lane()).parent {
if driving_lane.road == sidewalk_pos.lane().road {
Some(sidewalk_pos.equiv_pos(driving_lane, map))
} else {
Some(Position::start(driving_lane))

View File

@ -311,15 +311,15 @@ fn seed_parked_cars(
BTreeMap::new();
for spot in sim.get_all_parking_spots().1 {
let (r, restriction) = match spot {
ParkingSpot::Onstreet(l, _) => (map.get_l(l).parent, None),
ParkingSpot::Onstreet(l, _) => (l.road, None),
ParkingSpot::Offstreet(b, _) => (
map.get_l(map.get_b(b).sidewalk()).parent,
map.get_b(b).sidewalk().road,
match map.get_b(b).parking {
OffstreetParking::PublicGarage(_, _) => None,
OffstreetParking::Private(_, _) => Some(b),
},
),
ParkingSpot::Lot(pl, _) => (map.get_l(map.get_pl(pl).driving_pos.lane()).parent, None),
ParkingSpot::Lot(pl, _) => (map.get_pl(pl).driving_pos.lane().road, None),
};
open_spots_per_road
.entry(r)

View File

@ -1081,7 +1081,7 @@ impl DrivingSimState {
fn pick_overtaking_lane(&self, car: &Car, map: &Map) -> Option<LaneID> {
// Don't overtake in the middle of a turn!
let current_lane = map.get_l(car.router.head().maybe_lane()?);
let road = map.get_r(current_lane.parent);
let road = map.get_parent(current_lane.id);
let idx = road.offset(current_lane.id);
let mut candidates = Vec::new();