pub fn leave_from_driveway(
        start: Position,
        end: Position,
        constraints: PathConstraints,
        map: &Map,
    ) -> PathRequest {
        let alt_start = (|| {
            let start_lane = map.get_l(start.lane());
            let road = map.get_r(start_lane.parent);
            // 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 {
                return None;
            }
            let offside_dir = start_lane.dir.opposite();
            let alt_lane = road.find_closest_lane(
                start_lane.id,
                |l| l.dir == offside_dir && constraints.can_use(l, map),
                map,
            )?;
            // TODO Do we need buffer_dist like driving_connection does?
            let pos = start.equiv_pos(alt_lane, map);
            let number_lanes_between =
                ((road.offset(start_lane.id) as f64) - (road.offset(alt_lane) as f64)).abs();
            // TODO Tune the cost of cutting across lanes
            let cost = Duration::seconds(10.0) * number_lanes_between;
            Some((pos, cost))
        })();
        PathRequest {
            start,
            end,
            constraints,
            alt_start,
        }
    }
/// The caller must pass in two valid positions for the vehicle type. This isn't verified.
/// TODO The vehicle may cut exit the driveway onto the off-side of the road.
The caller must pass in two valid positions for the vehicle type. This isn't verified.
TODO The vehicle may cut exit the driveway onto the off-side of the road.
The caller must pass in two valid positions for the vehicle type . This isn ' t verified . TODO The vehicle may cut exit the driveway onto the off - side of the road .
pub fn leave_from_driveway(
        start: Position,
        end: Position,
        constraints: PathConstraints,
        map: &Map,
    ) -> PathRequest {
        let alt_start = (|| {
            let start_lane = map.get_l(start.lane());
            let road = map.get_r(start_lane.parent);
            // 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 {
                return None;
            }
            let offside_dir = start_lane.dir.opposite();
            let alt_lane = road.find_closest_lane(
                start_lane.id,
                |l| l.dir == offside_dir && constraints.can_use(l, map),
                map,
            )?;
            // TODO Do we need buffer_dist like driving_connection does?
            let pos = start.equiv_pos(alt_lane, map);
            let number_lanes_between =
                ((road.offset(start_lane.id) as f64) - (road.offset(alt_lane) as f64)).abs();
            // TODO Tune the cost of cutting across lanes
            let cost = Duration::seconds(10.0) * number_lanes_between;
            Some((pos, cost))
        })();
        PathRequest {
            start,
            end,
            constraints,
            alt_start,
        }
    }
pub fn leave_from_driveway ( start : Position , end : Position , constraints : PathConstraints , map : & Map , ) -> PathRequest { let alt_start = ( | | { let start_lane = map . get_l ( start . lane ( ) ) ; let road = map . get_r ( start_lane . parent ) ; // 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 { return None ; } let offside_dir = start_lane . dir . opposite ( ) ; let alt_lane = road . find_closest_lane ( start_lane . id , | l | l . dir == offside_dir && constraints . can_use ( l , map ) , map , ) ? ; // TODO Do we need buffer_dist like driving_connection does? let pos = start . equiv_pos ( alt_lane , map ) ; let number_lanes_between = ( ( road . offset ( start_lane . id ) as f64 ) - ( road . offset ( alt_lane ) as f64 ) ) . abs ( ) ; // TODO Tune the cost of cutting across lanes let cost = Duration :: seconds ( 10.0 ) * number_lanes_between ; Some ( ( pos , cost ) ) } ) ( ) ; PathRequest { start , end , constraints , alt_start , } }
The caller must pass in two valid positions for the vehicle type.
The caller must pass in two valid positions for the vehicle type .
start
Position
end
Position
constraints
PathConstraints
map
&Map