Crate rapidgeo_distance

Crate rapidgeo_distance 

Source
Expand description

Fast, accurate geographic and planar distance calculations.

This crate provides distance calculation functions for geographic coordinates using both geodesic (Earth-aware) and Euclidean (flat-plane) algorithms.

§Quick Start

use rapidgeo_distance::{LngLat, geodesic, euclid};

let sf = LngLat::new_deg(-122.4194, 37.7749);   // San Francisco
let nyc = LngLat::new_deg(-74.0060, 40.7128);   // New York City

// Haversine: Fast, ±0.5% accuracy for distances <1000km
let distance = geodesic::haversine(sf, nyc);
println!("Distance: {:.1} km", distance / 1000.0);

// Euclidean: Very fast but inaccurate for large distances
let euclidean = euclid::distance_euclid(sf, nyc);
println!("Euclidean: {:.6}°", euclidean);

§Algorithm Selection

AlgorithmSpeedAccuracyBest For
HaversineFast±0.5%General use, distances <1000km
VincentySlow±1mmHigh precision, any distance
EuclideanFastestPoorSmall areas, relative comparisons

§Coordinate System

All coordinates use the lng, lat ordering convention (longitude first, latitude second). Coordinates are stored in decimal degrees and converted to radians internally as needed. The geodesic calculations assume the WGS84 ellipsoid.

§Modules

Modules§

batch
Batch processing for high-performance distance calculations.
detection
Smart coordinate format detection with early termination optimization.
euclid
Euclidean (flat-plane) distance calculations.
format_batch
formats
geodesic
Geodesic (Earth-aware) distance calculations.

Structs§

LngLat
A geographic coordinate in decimal degrees.