Struct PlaneProjection

Source
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);

Implementations§

Source§

impl PlaneProjection

Source

pub fn new(latitude: f64) -> Self

Creates a plane projection to the Earth at provided latitude

Source

pub fn square_distance(&self, a: LatLon, b: LatLon) -> f64

Sqare distance in meters between two points in (lat, lon) format

Source

pub fn distance(&self, a: LatLon, b: LatLon) -> f64

Distance in meters between two points in (lat, lon) format

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.