Function calculate_haversine_distance

Source
pub fn calculate_haversine_distance<T>(
    point_a: Point2<T>,
    point_b: Point2<T>,
    sphere_radius: T,
) -> T
where T: Scalar + Float,
Expand description

Calculates the Haversine distance between two points on a sphere using floating-point arithmetic.

§Arguments

  • point_a: A [`Point2’] representing the first geographical point.
  • point_b: A Point2 representing the second geographical point.
  • sphere_radius: A T representing the radius of the sphere, typically the Earth’s radius in kilometers or miles.

§Generics

T: Either an f32 or f64

§Returns

A ‘T’, the distance between point_a and point_b along the surface of the sphere, using the Haversine formula.