1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! 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
//!
//! | Algorithm | Speed | Accuracy | Best For |
//! |-----------|-------|----------|----------|
//! | [Haversine](https://en.wikipedia.org/wiki/Haversine_formula) | Fast | ±0.5% | General use, distances <1000km |
//! | [Vincenty](https://en.wikipedia.org/wiki/Vincenty%27s_formulae) | Slow | ±1mm | High precision, any distance |
//! | [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) | Fastest | Poor | Small 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](https://en.wikipedia.org/wiki/World_Geodetic_System).
//!
//! # Modules
//!
//! - [`geodesic`]: Earth-aware distance calculations using [geodesic algorithms](https://en.wikipedia.org/wiki/Geodesic)
//! - [`euclid`]: Fast planar distance calculations using [Euclidean geometry](https://en.wikipedia.org/wiki/Euclidean_geometry)
//! - [`batch`]: Parallel batch operations (requires `batch` feature)
/// A geographic coordinate in decimal degrees.
///
/// Represents a point on Earth's surface using longitude and latitude in decimal degrees.
/// Follows the **lng, lat** ordering convention (longitude first, latitude second).
///
/// # Coordinate Bounds
///
/// - Longitude: -180.0 to +180.0 degrees (West to East)
/// - Latitude: -90.0 to +90.0 degrees (South to North)
///
/// # Examples
///
/// ```
/// use rapidgeo_distance::LngLat;
///
/// // San Francisco coordinates (lng, lat order)
/// let sf = LngLat::new_deg(-122.4194, 37.7749);
///
/// // Convert from radians
/// let coord = LngLat::new_rad(-2.1364, 0.6588);
///
/// // Convert to radians for calculations
/// let (lng_rad, lat_rad) = sf.to_radians();
/// ```