pub struct FlatPoint<T> {
pub x: T,
pub y: T,
}Expand description
Representation of a geographical point on Earth as projected
by a FlatProjection instance.
let (lon, lat) = (6.186389, 50.823194);
let proj = FlatProjection::new(6., 51.);
let flat_point = proj.project(lon, lat);Fields§
§x: TX-axis component of the flat-surface point in kilometers
y: TY-axis component of the flat-surface point in kilometers
Implementations§
Source§impl<T: Float> FlatPoint<T>
impl<T: Float> FlatPoint<T>
Sourcepub fn distance(&self, other: &FlatPoint<T>) -> T
pub fn distance(&self, other: &FlatPoint<T>) -> T
Calculates the approximate distance in kilometers from
this FlatPoint to another.
let (lon1, lat1) = (6.186389, 50.823194);
let (lon2, lat2) = (6.953333, 51.301389);
let proj = FlatProjection::new(6.5, 51.05);
let p1 = proj.project(lon1, lat1);
let p2 = proj.project(lon2, lat2);
let distance = p1.distance(&p2);
// -> 75.648 kmSourcepub fn distance_squared(&self, other: &FlatPoint<T>) -> T
pub fn distance_squared(&self, other: &FlatPoint<T>) -> T
Calculates the approximate squared distance from this FlatPoint to
another.
This method can be used for fast distance comparisons.
Sourcepub fn bearing(&self, other: &FlatPoint<T>) -> T
pub fn bearing(&self, other: &FlatPoint<T>) -> T
Calculates the approximate average bearing in degrees
between -180 and 180 from this FlatPoint to another.
let (lon1, lat1) = (6.186389, 50.823194);
let (lon2, lat2) = (6.953333, 51.301389);
let proj = FlatProjection::new(6.5, 51.05);
let p1 = proj.project(lon1, lat1);
let p2 = proj.project(lon2, lat2);
let bearing = p1.bearing(&p2);
// -> 45.3°Sourcepub fn distance_bearing(&self, other: &FlatPoint<T>) -> (T, T)
pub fn distance_bearing(&self, other: &FlatPoint<T>) -> (T, T)
Calculates the approximate distance and average bearing
from this FlatPoint to another.
let (lon1, lat1) = (6.186389, 50.823194);
let (lon2, lat2) = (6.953333, 51.301389);
let proj = FlatProjection::new(6.5, 51.05);
let p1 = proj.project(lon1, lat1);
let p2 = proj.project(lon2, lat2);
let (distance, bearing) = p1.distance_bearing(&p2);
// -> 75.648 km and 45.3°Sourcepub fn destination(&self, dist: T, bearing: T) -> FlatPoint<T>
pub fn destination(&self, dist: T, bearing: T) -> FlatPoint<T>
Trait Implementations§
Source§impl<T: PartialOrd> PartialOrd for FlatPoint<T>
impl<T: PartialOrd> PartialOrd for FlatPoint<T>
impl<T: Copy> Copy for FlatPoint<T>
impl<T> StructuralPartialEq for FlatPoint<T>
Auto Trait Implementations§
impl<T> Freeze for FlatPoint<T>where
T: Freeze,
impl<T> RefUnwindSafe for FlatPoint<T>where
T: RefUnwindSafe,
impl<T> Send for FlatPoint<T>where
T: Send,
impl<T> Sync for FlatPoint<T>where
T: Sync,
impl<T> Unpin for FlatPoint<T>where
T: Unpin,
impl<T> UnwindSafe for FlatPoint<T>where
T: UnwindSafe,
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