fix PSRC trips with borders on larger maps

This commit is contained in:
Dustin Carlino 2019-06-01 17:33:44 -07:00
parent 314489c63f
commit 661fedaa28
2 changed files with 37 additions and 46 deletions

View File

@ -38,26 +38,32 @@ impl Trip {
match self.mode { match self.mode {
Mode::Walk => PathRequest { Mode::Walk => PathRequest {
start: self.from.start_pos_walking(map), start: self.from.start_sidewalk_spot(map).sidewalk_pos,
end: self.from.end_pos_walking(map), end: self.from.end_sidewalk_spot(map).sidewalk_pos,
can_use_bike_lanes: false, can_use_bike_lanes: false,
can_use_bus_lanes: false, can_use_bus_lanes: false,
}, },
Mode::Bike => PathRequest { Mode::Bike => PathRequest {
start: self.from.start_pos_driving(map), start: self.from.start_pos_driving(map),
end: self.to.end_pos_driving(map), end: self
.to
.driving_goal(vec![LaneType::Biking, LaneType::Driving], map)
.goal_pos(map),
can_use_bike_lanes: true, can_use_bike_lanes: true,
can_use_bus_lanes: false, can_use_bus_lanes: false,
}, },
Mode::Drive => PathRequest { Mode::Drive => PathRequest {
start: self.from.start_pos_driving(map), start: self.from.start_pos_driving(map),
end: self.to.end_pos_driving(map), end: self
.to
.driving_goal(vec![LaneType::Driving], map)
.goal_pos(map),
can_use_bike_lanes: false, can_use_bike_lanes: false,
can_use_bus_lanes: false, can_use_bus_lanes: false,
}, },
Mode::Transit => { Mode::Transit => {
let start = self.from.start_pos_walking(map); let start = self.from.start_sidewalk_spot(map).sidewalk_pos;
let end = self.to.end_pos_walking(map); let end = self.to.end_sidewalk_spot(map).sidewalk_pos;
if let Some((stop1, _, _)) = map.should_use_transit(start, end) { if let Some((stop1, _, _)) = map.should_use_transit(start, end) {
PathRequest { PathRequest {
start, start,
@ -100,26 +106,6 @@ impl TripEndpt {
}) })
} }
fn start_pos_walking(&self, map: &Map) -> Position {
match self {
TripEndpt::Building(b) => Position::bldg_via_walking(*b, map),
TripEndpt::Border(i, _) => {
let lane = map.get_i(*i).get_outgoing_lanes(map, LaneType::Sidewalk)[0];
Position::new(lane, Distance::ZERO)
}
}
}
fn end_pos_walking(&self, map: &Map) -> Position {
match self {
TripEndpt::Building(b) => Position::bldg_via_walking(*b, map),
TripEndpt::Border(i, _) => {
let lane = map.get_i(*i).get_incoming_lanes(map, LaneType::Sidewalk)[0];
Position::new(lane, map.get_l(lane).length())
}
}
}
fn start_sidewalk_spot(&self, map: &Map) -> SidewalkSpot { fn start_sidewalk_spot(&self, map: &Map) -> SidewalkSpot {
match self { match self {
TripEndpt::Building(b) => SidewalkSpot::building(*b, map), TripEndpt::Building(b) => SidewalkSpot::building(*b, map),
@ -146,16 +132,6 @@ impl TripEndpt {
} }
} }
fn end_pos_driving(&self, map: &Map) -> Position {
match self {
TripEndpt::Building(b) => Position::bldg_via_driving(*b, map).unwrap(),
TripEndpt::Border(i, _) => {
let lane = map.get_i(*i).get_incoming_lanes(map, LaneType::Driving)[0];
Position::new(lane, map.get_l(lane).length())
}
}
}
fn driving_goal(&self, lane_types: Vec<LaneType>, map: &Map) -> DrivingGoal { fn driving_goal(&self, lane_types: Vec<LaneType>, map: &Map) -> DrivingGoal {
match self { match self {
TripEndpt::Building(b) => DrivingGoal::ParkNear(*b), TripEndpt::Building(b) => DrivingGoal::ParkNear(*b),

View File

@ -262,28 +262,43 @@ impl SidewalkSpot {
} }
} }
// Recall sidewalks are bidirectional.
pub fn start_at_border(i: IntersectionID, map: &Map) -> Option<SidewalkSpot> { pub fn start_at_border(i: IntersectionID, map: &Map) -> Option<SidewalkSpot> {
let lanes = map.get_i(i).get_outgoing_lanes(map, LaneType::Sidewalk); let lanes = map.get_i(i).get_outgoing_lanes(map, LaneType::Sidewalk);
if lanes.is_empty() { if !lanes.is_empty() {
None return Some(SidewalkSpot {
} else {
Some(SidewalkSpot {
sidewalk_pos: Position::new(lanes[0], Distance::ZERO), sidewalk_pos: Position::new(lanes[0], Distance::ZERO),
connection: SidewalkPOI::Border(i), connection: SidewalkPOI::Border(i),
}) });
} }
let lanes = map.get_i(i).get_incoming_lanes(map, LaneType::Sidewalk);
if lanes.is_empty() {
return None;
}
Some(SidewalkSpot {
sidewalk_pos: Position::new(lanes[0], map.get_l(lanes[0]).length()),
connection: SidewalkPOI::Border(i),
})
} }
pub fn end_at_border(i: IntersectionID, map: &Map) -> Option<SidewalkSpot> { pub fn end_at_border(i: IntersectionID, map: &Map) -> Option<SidewalkSpot> {
let lanes = map.get_i(i).get_incoming_lanes(map, LaneType::Sidewalk); let lanes = map.get_i(i).get_incoming_lanes(map, LaneType::Sidewalk);
if lanes.is_empty() { if !lanes.is_empty() {
None return Some(SidewalkSpot {
} else {
Some(SidewalkSpot {
sidewalk_pos: Position::new(lanes[0], map.get_l(lanes[0]).length()), sidewalk_pos: Position::new(lanes[0], map.get_l(lanes[0]).length()),
connection: SidewalkPOI::Border(i), connection: SidewalkPOI::Border(i),
}) });
} }
let lanes = map.get_i(i).get_outgoing_lanes(map, LaneType::Sidewalk);
if lanes.is_empty() {
return None;
}
Some(SidewalkSpot {
sidewalk_pos: Position::new(lanes[0], Distance::ZERO),
connection: SidewalkPOI::Border(i),
})
} }
pub fn suddenly_appear(l: LaneID, dist: Distance, map: &Map) -> SidewalkSpot { pub fn suddenly_appear(l: LaneID, dist: Distance, map: &Map) -> SidewalkSpot {