Trait geo::algorithm::haversine_distance::HaversineDistance[][src]

pub trait HaversineDistance<T, Rhs = Self> {
    fn haversine_distance(&self, rhs: &Rhs) -> T;
}

Determine the distance between two geometries using the haversine formula.

Note: this implementation uses a mean earth radius of 6371.088 km, based on the recommendation of the IUGG

Required methods

fn haversine_distance(&self, rhs: &Rhs) -> T[src]

Determine the distance between two geometries using the haversine formula.

Units

  • return value: meters

Examples

use geo::prelude::*;
use geo::point;

// New York City
let p1 = point!(x: -74.006f64, y: 40.7128f64);

// London
let p2 = point!(x: -0.1278f64, y: 51.5074f64);

let distance = p1.haversine_distance(&p2);

assert_eq!(
    5_570_230., // meters
    distance.round()
);
Loading content...

Implementors

impl<T> HaversineDistance<T, Point<T>> for Point<T> where
    T: CoordFloat + FromPrimitive
[src]

Loading content...