[][src]Trait geo::algorithm::line_locate_point::LineLocatePoint

pub trait LineLocatePoint<T, Rhs> {
    type Output;
    type Rhs;
    fn line_locate_point(&self, p: &Rhs) -> Self::Output;
}

Returns a fraction of the line's total length representing the location of the closest point on the line to the given point.

Examples

use geo::{LineString, point};
use geo::algorithm::line_locate_point::LineLocatePoint;

let linestring: LineString<f64> = vec![
    [-1.0, 0.0],
    [0.0, 0.0],
    [0.0, 1.0]
].into();

assert_eq!(linestring.line_locate_point(&point!(x: -1.0, y: 0.0)), 0.0);
assert_eq!(linestring.line_locate_point(&point!(x: -0.5, y: 0.0)), 0.25);
assert_eq!(linestring.line_locate_point(&point!(x: 0.0, y: 0.0)), 0.5);
assert_eq!(linestring.line_locate_point(&point!(x: 0.0, y: 0.5)), 0.75);
assert_eq!(linestring.line_locate_point(&point!(x: 0.0, y: 1.0)), 1.0);

Associated Types

type Output

type Rhs

Loading content...

Required methods

fn line_locate_point(&self, p: &Rhs) -> Self::Output

Loading content...

Implementors

impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
    T: CoordinateType + Float + Zero + One
[src]

type Output = T

type Rhs = Point<T>

impl<T> LineLocatePoint<T, Point<T>> for LineString<T> where
    T: CoordinateType + Float + Zero + One + PartialOrd + AddAssign,
    Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>, 
[src]

type Output = T

type Rhs = Point<T>

Loading content...