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

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§

source

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

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()
);

Implementors§