pub fn trace_from_start(&self, map: &Map, start_dist: Distance) -> Option<PolyLine> {
        let orig_end_dist = self.orig_req.end.dist_along();

        if self.steps.len() == 1 {
            let dist_ahead = if start_dist < orig_end_dist {
                orig_end_dist - start_dist
            } else {
                start_dist - orig_end_dist
            };

            // Why might this fail? It's possible there are paths on their last step that're
            // effectively empty, because they're a 0-length turn, or something like a pedestrian
            // crossing a front path and immediately getting on a bike.
            return self.steps[0]
                .exact_slice(map, start_dist, Some(dist_ahead))
                .ok();
        }

        let mut pts_so_far: Option<PolyLine> = None;

        // Special case the first step with start_dist.
        if let Ok(pts) = self.steps[0].exact_slice(map, start_dist, None) {
            pts_so_far = Some(pts);
        }

        // Crunch through the intermediate steps, as long as we can.
        for i in 1..self.steps.len() {
            // Restrict the last step's slice
            let dist_ahead = if i == self.steps.len() - 1 {
                Some(match self.steps[i] {
                    PathStep::ContraflowLane(l) => {
                        map.get_l(l).lane_center_pts.reversed().length() - orig_end_dist
                    }
                    _ => orig_end_dist,
                })
            } else {
                None
            };

            let start_dist_this_step = match self.steps[i] {
                // TODO Length of a PolyLine can slightly change when points are reversed! That
                // seems bad.
                PathStep::ContraflowLane(l) => map.get_l(l).lane_center_pts.reversed().length(),
                _ => Distance::ZERO,
            };
            if let Ok(new_pts) = self.steps[i].exact_slice(map, start_dist_this_step, dist_ahead) {
                if pts_so_far.is_some() {
                    match pts_so_far.unwrap().extend(new_pts) {
                        Ok(new) => {
                            pts_so_far = Some(new);
                        }
                        Err(err) => {
                            println!("WARNING: Couldn't trace some path: {}", err);
                            return None;
                        }
                    }
                } else {
                    pts_so_far = Some(new_pts);
                }
            }
        }

        Some(pts_so_far.unwrap())
    }
/// Traces along the path from a specified distance along the first step until the end.
Traces along the path from a specified distance along the first step until the end.
Traces along the path from a specified distance along the first step until the end .
pub fn trace_from_start(&self, map: &Map, start_dist: Distance) -> Option<PolyLine> {
        let orig_end_dist = self.orig_req.end.dist_along();
        if self.steps.len() == 1 {
            let dist_ahead = if start_dist < orig_end_dist {
                orig_end_dist - start_dist
            } else {
                start_dist - orig_end_dist
            };
            // Why might this fail? It's possible there are paths on their last step that're
            // effectively empty, because they're a 0-length turn, or something like a pedestrian
            // crossing a front path and immediately getting on a bike.
            return self.steps[0]
                .exact_slice(map, start_dist, Some(dist_ahead))
                .ok();
        }
        let mut pts_so_far: Option<PolyLine> = None;
        // Special case the first step with start_dist.
        if let Ok(pts) = self.steps[0].exact_slice(map, start_dist, None) {
            pts_so_far = Some(pts);
        }
        // Crunch through the intermediate steps, as long as we can.
        for i in 1..self.steps.len() {
            // Restrict the last step's slice
            let dist_ahead = if i == self.steps.len() - 1 {
                Some(match self.steps[i] {
                    PathStep::ContraflowLane(l) => {
                        map.get_l(l).lane_center_pts.reversed().length() - orig_end_dist
                    }
                    _ => orig_end_dist,
                })
            } else {
                None
            };
            let start_dist_this_step = match self.steps[i] {
                // TODO Length of a PolyLine can slightly change when points are reversed! That
                // seems bad.
                PathStep::ContraflowLane(l) => map.get_l(l).lane_center_pts.reversed().length(),
                _ => Distance::ZERO,
            };
            if let Ok(new_pts) = self.steps[i].exact_slice(map, start_dist_this_step, dist_ahead) {
                if pts_so_far.is_some() {
                    match pts_so_far.unwrap().extend(new_pts) {
                        Ok(new) => {
                            pts_so_far = Some(new);
                        }
                        Err(err) => {
                            println!("WARNING: Couldn't trace some path: {}", err);
                            return None;
                        }
                    }
                } else {
                    pts_so_far = Some(new_pts);
                }
            }
        }
        Some(pts_so_far.unwrap())
    }
pub fn trace_from_start ( & self , map : & Map , start_dist : Distance ) -> Option < PolyLine > { let orig_end_dist = self . orig_req . end . dist_along ( ) ; if self . steps . len ( ) == 1 { let dist_ahead = if start_dist < orig_end_dist { orig_end_dist - start_dist } else { start_dist - orig_end_dist } ; // Why might this fail? It's possible there are paths on their last step that're // effectively empty, because they're a 0-length turn, or something like a pedestrian // crossing a front path and immediately getting on a bike. return self . steps [ 0 ] . exact_slice ( map , start_dist , Some ( dist_ahead ) ) . ok ( ) ; } let mut pts_so_far : Option < PolyLine > = None ; // Special case the first step with start_dist. if let Ok ( pts ) = self . steps [ 0 ] . exact_slice ( map , start_dist , None ) { pts_so_far = Some ( pts ) ; } // Crunch through the intermediate steps, as long as we can. for i in 1 .. self . steps . len ( ) { // Restrict the last step's slice let dist_ahead = if i == self . steps . len ( ) - 1 { Some ( match self . steps [ i ] { PathStep :: ContraflowLane ( l ) => { map . get_l ( l ) . lane_center_pts . reversed ( ) . length ( ) - orig_end_dist } _ => orig_end_dist , } ) } else { None } ; let start_dist_this_step = match self . steps [ i ] { // TODO Length of a PolyLine can slightly change when points are reversed! That // seems bad. PathStep :: ContraflowLane ( l ) => map . get_l ( l ) . lane_center_pts . reversed ( ) . length ( ) , _ => Distance :: ZERO , } ; if let Ok ( new_pts ) = self . steps [ i ] . exact_slice ( map , start_dist_this_step , dist_ahead ) { if pts_so_far . is_some ( ) { match pts_so_far . unwrap ( ) . extend ( new_pts ) { Ok ( new ) => { pts_so_far = Some ( new ) ; } Err ( err ) => { println ! ( " " err ) ; return None ; } } } else { pts_so_far = Some ( new_pts ) ; } } } Some ( pts_so_far . unwrap ( ) ) }
Traces along the path from a specified distance along the first step until the end.
Traces along the path from a specified distance along the first step until the end .
&self
map
&Map
start_dist
Distance