pub struct PlaneProjection { /* private fields */ }
Expand description
A plane projection, useful for blazingly fast approximate distance calculations. Based on WGS84 ellipsoid model of the Earth, plane projection provides 0.1% precision on distances under 500km at latitudes up to the 65°. See https://blog.mapbox.com/fast-geodesic-approximations-with-cheap-ruler-106f229ad016 for more details about the principle and formulas behind.
use plane_projection::PlaneProjection;
let proj = PlaneProjection::new(55.65);
let distance = proj.distance((55.704141722528554, 13.191304107330561), (55.60330902847681, 13.001973666557435));
assert_eq!(distance as u32, 16373);
let heading = proj.heading((55.704141722528554, 13.191304107330561), (55.60330902847681, 13.001973666557435));
assert_eq!(heading as u32, 226);
Implementations§
Source§impl PlaneProjection
impl PlaneProjection
Sourcepub fn new(latitude: f64) -> Self
pub fn new(latitude: f64) -> Self
Creates a plane projection to the Earth at provided latitude.
Sourcepub fn project(&self, ll: LatLon) -> (f64, f64)
pub fn project(&self, ll: LatLon) -> (f64, f64)
Projects a coordinate from (latitude, longitude) to the plane projection space.
This function is intended for low-level coordinate manipulation (like vector math) in the projection space
and should not be used unless the built-in methods like PlaneProjection::distance()
and
PlaneProjection::distance_to_segment()
are insufficient for your use case.
Sourcepub fn square_distance(&self, a: LatLon, b: LatLon) -> f64
pub fn square_distance(&self, a: LatLon, b: LatLon) -> f64
Square distance in meters between two points in (lat, lon) format.
Sourcepub fn distance(&self, a: LatLon, b: LatLon) -> f64
pub fn distance(&self, a: LatLon, b: LatLon) -> f64
Distance in meters between two points in (lat, lon) format.
Sourcepub fn square_distance_to_segment(
&self,
point: LatLon,
segment: (LatLon, LatLon),
) -> f64
pub fn square_distance_to_segment( &self, point: LatLon, segment: (LatLon, LatLon), ) -> f64
Square distance in meters from point to the segment.
Trait Implementations§
Source§impl Clone for PlaneProjection
impl Clone for PlaneProjection
Source§fn clone(&self) -> PlaneProjection
fn clone(&self) -> PlaneProjection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more