pub struct WGS84<N> { /* private fields */ }
Expand description
Geodetic position
This struct represents a position in the geodetic system on the WGS84
ellipsoid.
See: WGS84 for
more information.
The serde
feature allows this to be Serialized / Deserialized.
If serialized into json, it will look like this. Enabled thought
the serde
feature
{
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0
}
Note: latitude and longitude values will be in radians
Implementations§
source§impl<N: RealFieldCopy> WGS84<N>where
f64: From<N>,
impl<N: RealFieldCopy> WGS84<N>where f64: From<N>,
sourcepub fn from_degrees_and_meters(
latitude: N,
longitude: N,
altitude: N
) -> WGS84<N>
pub fn from_degrees_and_meters( latitude: N, longitude: N, altitude: N ) -> WGS84<N>
sourcepub fn try_from_degrees_and_meters(
latitude: N,
longitude: N,
altitude: N
) -> Option<WGS84<N>>
pub fn try_from_degrees_and_meters( latitude: N, longitude: N, altitude: N ) -> Option<WGS84<N>>
Try to create a new WGS84 position
Arguments
latitude
in degreeslongitude
in degreesaltitude
in meters
sourcepub fn from_radians_and_meters(
latitude: N,
longitude: N,
altitude: N
) -> WGS84<N>
pub fn from_radians_and_meters( latitude: N, longitude: N, altitude: N ) -> WGS84<N>
sourcepub fn try_from_radians_and_meters(
latitude: N,
longitude: N,
altitude: N
) -> Option<WGS84<N>>
pub fn try_from_radians_and_meters( latitude: N, longitude: N, altitude: N ) -> Option<WGS84<N>>
Try to create a new WGS84 position
Arguments
latitude
in radianslongitude
in radiansaltitude
in meters
sourcepub fn latitude_degrees(&self) -> N
pub fn latitude_degrees(&self) -> N
Get latitude of position, in degrees
sourcepub fn longitude_degrees(&self) -> N
pub fn longitude_degrees(&self) -> N
Get longitude of position, in degrees
sourcepub fn distance(&self, other: &WGS84<N>) -> N
pub fn distance(&self, other: &WGS84<N>) -> N
Distance between two WGS84 positions
This function uses the haversin formula to calculate the distance between two positions. For more control convert to ECEF and calculate the difference.
Examples
use nav_types::WGS84;
let oslo = WGS84::from_degrees_and_meters(59.95, 10.75, 0.0);
let stockholm = WGS84::from_degrees_and_meters(59.329444, 18.068611, 0.0);
println!("Great circle distance between Oslo and Stockholm: {:?}",
oslo.distance(&stockholm));
source§impl<N: Copy> WGS84<N>
impl<N: Copy> WGS84<N>
sourcepub fn latitude_radians(&self) -> N
pub fn latitude_radians(&self) -> N
Get latitude of position, in radians
sourcepub fn longitude_radians(&self) -> N
pub fn longitude_radians(&self) -> N
Get longitude of position, in radians
Trait Implementations§
source§impl<N, T> AddAssign<T> for WGS84<N>where
N: RealFieldCopy + AddAssign,
T: Into<ENU<N>>,
impl<N, T> AddAssign<T> for WGS84<N>where N: RealFieldCopy + AddAssign, T: Into<ENU<N>>,
source§fn add_assign(&mut self, right: T)
fn add_assign(&mut self, right: T)
Performs the
+=
operation. Read moresource§impl<N: PartialEq> PartialEq<WGS84<N>> for WGS84<N>
impl<N: PartialEq> PartialEq<WGS84<N>> for WGS84<N>
source§impl<N, T> SubAssign<T> for WGS84<N>where
N: RealFieldCopy + SubAssign,
T: Into<ENU<N>>,
impl<N, T> SubAssign<T> for WGS84<N>where N: RealFieldCopy + SubAssign, T: Into<ENU<N>>,
source§fn sub_assign(&mut self, right: T)
fn sub_assign(&mut self, right: T)
Performs the
-=
operation. Read moreimpl<N: Copy> Copy for WGS84<N>
impl<N> StructuralPartialEq for WGS84<N>
Auto Trait Implementations§
impl<N> RefUnwindSafe for WGS84<N>where N: RefUnwindSafe,
impl<N> Send for WGS84<N>where N: Send,
impl<N> Sync for WGS84<N>where N: Sync,
impl<N> Unpin for WGS84<N>where N: Unpin,
impl<N> UnwindSafe for WGS84<N>where N: 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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.