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 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.
Auto Trait Implementations§
impl Freeze for PlaneProjection
impl RefUnwindSafe for PlaneProjection
impl Send for PlaneProjection
impl Sync for PlaneProjection
impl Unpin for PlaneProjection
impl UnwindSafe for PlaneProjection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more