pub fn length_from(&self, point: &Coord, direction: Direction) -> f64{
        //let nearest_point = self.distance_from_nearest_point(point).1;
        let mut distance = 0.0;
        match direction{
            Direction::Forward => {
                for segment in &self.into_segments() {
                    if segment.strictly_contains(point){
                        distance += segment.a.distance(point);
                        break;
                    } else {
                        distance += segment.length();
                    }
                }
            },
            Direction::Backward => {
                for segment in self.into_segments().iter().rev(){
                    if segment.strictly_contains(point){
                        distance += segment.reverse().a.distance(point);
                        break;
                    } else {
                        distance += segment.length();
                    }
                }
            }
        }
        distance
    }
/// Get the distance from a point to an end of the road
Get the distance from a point to an end of the road
Get the distance from a point to an end of the road
pub fn length_from(&self, point: &Coord, direction: Direction) -> f64{
        //let nearest_point = self.distance_from_nearest_point(point).1;
        let mut distance = 0.0;
        match direction{
            Direction::Forward => {
                for segment in &self.into_segments() {
                    if segment.strictly_contains(point){
                        distance += segment.a.distance(point);
                        break;
                    } else {
                        distance += segment.length();
                    }
                }
            },
            Direction::Backward => {
                for segment in self.into_segments().iter().rev(){
                    if segment.strictly_contains(point){
                        distance += segment.reverse().a.distance(point);
                        break;
                    } else {
                        distance += segment.length();
                    }
                }
            }
        }
        distance
    }
pub fn length_from ( & self , point : & Coord , direction : Direction ) -> f64 { //let nearest_point = self.distance_from_nearest_point(point).1; let mut distance = 0.0 ; match direction { Direction :: Forward => { for segment in & self . into_segments ( ) { if segment . strictly_contains ( point ) { distance += segment . a . distance ( point ) ; break ; } else { distance += segment . length ( ) ; } } } , Direction :: Backward => { for segment in self . into_segments ( ) . iter ( ) . rev ( ) { if segment . strictly_contains ( point ) { distance += segment . reverse ( ) . a . distance ( point ) ; break ; } else { distance += segment . length ( ) ; } } } } distance }
Get the distance from a point to an end of the road
Get the distance from a point to an end of the road
&self
point
&Coord
direction
Direction
&self
point
&Coord
direction
Direction