Trait geo::algorithm::line_locate_point::LineLocatePoint [−][src]
pub trait LineLocatePoint<T, Rhs> { type Output; type Rhs; fn line_locate_point(&self, p: &Rhs) -> Self::Output; }
Returns a (option of the) fraction of the line’s total length representing the location of the closest point on the line to the given point.
If the line has zero length the fraction returned is zero.
If either the point’s coordinates or any coordinates of the line
are not finite, returns None
.
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)), Some(0.0)); assert_eq!(linestring.line_locate_point(&point!(x: -0.5, y: 0.0)), Some(0.25)); assert_eq!(linestring.line_locate_point(&point!(x: 0.0, y: 0.0)), Some(0.5)); assert_eq!(linestring.line_locate_point(&point!(x: 0.0, y: 0.5)), Some(0.75)); assert_eq!(linestring.line_locate_point(&point!(x: 0.0, y: 1.0)), Some(1.0));
Associated Types
Loading content...Required methods
fn line_locate_point(&self, p: &Rhs) -> Self::Output
[src]
Implementors
impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordFloat,
[src]
T: CoordFloat,
type Output = Option<T>
type Rhs = Point<T>
fn line_locate_point(&self, p: &Self::Rhs) -> Self::Output
[src]
impl<T> LineLocatePoint<T, Point<T>> for LineString<T> where
T: CoordFloat + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
[src]
T: CoordFloat + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,