pub trait LineInterpolatePoint<F: CoordFloat> {
    type Output;

    // Required method
    fn line_interpolate_point(&self, fraction: F) -> Self::Output;
}
Expand description

Returns an option of the point that lies a given fraction along the line.

If the given fraction is

  • less than zero (including negative infinity): returns a Some of the starting point
  • greater than one (including infinity): returns a Some of the ending point

If either the fraction is NaN, or any coordinates of the line are not finite, returns None.

§Examples

use geo::{LineString, point};
use geo::LineInterpolatePoint;

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

assert_eq!(linestring.line_interpolate_point(-1.0), Some(point!(x: -1.0, y: 0.0)));
assert_eq!(linestring.line_interpolate_point(0.25), Some(point!(x: -0.5, y: 0.0)));
assert_eq!(linestring.line_interpolate_point(0.5), Some(point!(x: 0.0, y: 0.0)));
assert_eq!(linestring.line_interpolate_point(0.75), Some(point!(x: 0.0, y: 0.5)));
assert_eq!(linestring.line_interpolate_point(2.0), Some(point!(x: 0.0, y: 1.0)));

Required Associated Types§

Required Methods§

source

fn line_interpolate_point(&self, fraction: F) -> Self::Output

Implementors§