fn exact_slice(
        &self,
        map: &Map,
        start: Distance,
        dist_ahead: Option<Distance>,
    ) -> Result<PolyLine> {
        if let Some(d) = dist_ahead {
            if d < Distance::ZERO {
                panic!("Negative dist_ahead?! {}", d);
            }
            if d == Distance::ZERO {
                bail!("0 dist ahead for slice");
            }
        }

        match self {
            PathStep::Lane(id) => {
                let pts = &map.get_l(*id).lane_center_pts;
                if let Some(d) = dist_ahead {
                    pts.maybe_exact_slice(start, start + d)
                } else {
                    pts.maybe_exact_slice(start, pts.length())
                }
            }
            PathStep::ContraflowLane(id) => {
                let pts = map.get_l(*id).lane_center_pts.reversed();
                let reversed_start = pts.length() - start;
                if let Some(d) = dist_ahead {
                    pts.maybe_exact_slice(reversed_start, reversed_start + d)
                } else {
                    pts.maybe_exact_slice(reversed_start, pts.length())
                }
            }
            PathStep::Turn(id) => {
                let pts = &map.get_t(*id).geom;
                if let Some(d) = dist_ahead {
                    pts.maybe_exact_slice(start, start + d)
                } else {
                    pts.maybe_exact_slice(start, pts.length())
                }
            }
        }
    }
// start is relative to the start of the actual geometry -- so from the lane's real start for
// ContraflowLane.
start is relative to the start of the actual geometry -- so from the lane's real start for
ContraflowLane.
start is relative to the start of the actual geometry -- so from the lane ' s real start for ContraflowLane .
fn exact_slice(
        &self,
        map: &Map,
        start: Distance,
        dist_ahead: Option<Distance>,
    ) -> Result<PolyLine> {
        if let Some(d) = dist_ahead {
            if d < Distance::ZERO {
                panic!("Negative dist_ahead?! {}", d);
            }
            if d == Distance::ZERO {
                bail!("0 dist ahead for slice");
            }
        }
        match self {
            PathStep::Lane(id) => {
                let pts = &map.get_l(*id).lane_center_pts;
                if let Some(d) = dist_ahead {
                    pts.maybe_exact_slice(start, start + d)
                } else {
                    pts.maybe_exact_slice(start, pts.length())
                }
            }
            PathStep::ContraflowLane(id) => {
                let pts = map.get_l(*id).lane_center_pts.reversed();
                let reversed_start = pts.length() - start;
                if let Some(d) = dist_ahead {
                    pts.maybe_exact_slice(reversed_start, reversed_start + d)
                } else {
                    pts.maybe_exact_slice(reversed_start, pts.length())
                }
            }
            PathStep::Turn(id) => {
                let pts = &map.get_t(*id).geom;
                if let Some(d) = dist_ahead {
                    pts.maybe_exact_slice(start, start + d)
                } else {
                    pts.maybe_exact_slice(start, pts.length())
                }
            }
        }
    }
fn exact_slice ( & self , map : & Map , start : Distance , dist_ahead : Option < Distance > , ) -> Result < PolyLine > { if let Some ( d ) = dist_ahead { if d < Distance :: ZERO { panic ! ( " " d ) ; } if d == Distance :: ZERO { bail ! ( " " ) ; } } match self { PathStep :: Lane ( id ) => { let pts = & map . get_l ( * id ) . lane_center_pts ; if let Some ( d ) = dist_ahead { pts . maybe_exact_slice ( start , start + d ) } else { pts . maybe_exact_slice ( start , pts . length ( ) ) } } PathStep :: ContraflowLane ( id ) => { let pts = map . get_l ( * id ) . lane_center_pts . reversed ( ) ; let reversed_start = pts . length ( ) - start ; if let Some ( d ) = dist_ahead { pts . maybe_exact_slice ( reversed_start , reversed_start + d ) } else { pts . maybe_exact_slice ( reversed_start , pts . length ( ) ) } } PathStep :: Turn ( id ) => { let pts = & map . get_t ( * id ) . geom ; if let Some ( d ) = dist_ahead { pts . maybe_exact_slice ( start , start + d ) } else { pts . maybe_exact_slice ( start , pts . length ( ) ) } } } }
start is relative to the start of the actual geometry -- so from the lane's real start for
ContraflowLane.
start is relative to the start of the actual geometry -- so from the lane ' s real start for ContraflowLane .
&self
map
&Map
start
Distance
dist_ahead
Option<Distance>