pub trait HaversineClosestPoint<T>{
    // Required method
    fn haversine_closest_point(&self, from: &Point<T>) -> Closest<T>;
}
Expand description

Calculates the closest Point on a geometry from a given Point in sperical coordinates.

Similar to ClosestPoint but for spherical coordinates:

  • Longitude (x) in the [-180; 180] degrees range.
  • Latitude (y) in the [-90; 90] degrees range.

The implementation is based on https://edwilliams.org/avform147.htm#XTE.

See Closest<F> for a description of the return states.

Note: This may return Closest::Intersection even for non-intersecting geometies if they are very close to the input.

Example:

use approx::assert_relative_eq;
let line = Line::new(Point::new(-85.93942, 32.11055), Point::new(-84.74905, 32.61454));
let p_from = Point::new(-84.75625, 31.81056);
if let Closest::SinglePoint(pt) = line.haversine_closest_point(&p_from) {
    assert_relative_eq!(pt, Point::new(-85.13337428852164, 32.45365659858937), epsilon = 1e-6);
} else {
    panic!("Closest::SinglePoint expected");
}

Required Methods§

source

fn haversine_closest_point(&self, from: &Point<T>) -> Closest<T>

Implementations on Foreign Types§

source§

impl<'a, T, G> HaversineClosestPoint<T> for &'a G

source§

fn haversine_closest_point(&self, from: &Point<T>) -> Closest<T>

Implementors§