[−][src]Trait geo::algorithm::line_locate_point::LineLocatePoint
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
pub fn line_locate_point(&self, p: &Rhs) -> Self::Output
[src]
Implementors
impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordinateType + Float,
[src]
T: CoordinateType + Float,
type Output = Option<T>
type Rhs = Point<T>
pub fn line_locate_point(&self, p: &Self::Rhs) -> Self::Output
[src]
impl<T> LineLocatePoint<T, Point<T>> for LineString<T> where
T: CoordinateType + Float + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
[src]
T: CoordinateType + Float + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,