Struct nav_types::WGS84

source ·
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>,

source

pub fn from_degrees_and_meters( latitude: N, longitude: N, altitude: N ) -> WGS84<N>

Create a new WGS84 position

Arguments
  • latitude in degrees
  • longitude in degrees
  • altitude in meters
Panics

This will panic if latitude or longitude are not defined on the WGS84 ellipsoid.

source

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 degrees
  • longitude in degrees
  • altitude in meters
source

pub fn from_radians_and_meters( latitude: N, longitude: N, altitude: N ) -> WGS84<N>

Create a new WGS84 position

Arguments
  • latitude in radians
  • longitude in radians
  • altitude in meters
Panics

This will panic if latitude or longitude are not defined on the WGS84 ellipsoid.

source

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 radians
  • longitude in radians
  • altitude in meters
source

pub fn latitude_degrees(&self) -> N

Get latitude of position, in degrees

source

pub fn longitude_degrees(&self) -> N

Get longitude of position, in degrees

source

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>

source

pub fn altitude(&self) -> N

Get altitude of position, in meters

source

pub fn latitude_radians(&self) -> N

Get latitude of position, in radians

source

pub fn longitude_radians(&self) -> N

Get longitude of position, in radians

Trait Implementations§

source§

impl<N, T> Add<T> for WGS84<N>where N: RealFieldCopy, T: Into<ENU<N>>,

§

type Output = WGS84<N>

The resulting type after applying the + operator.
source§

fn add(self, right: T) -> Self

Performs the + operation. Read more
source§

impl<N, T> AddAssign<T> for WGS84<N>where N: RealFieldCopy + AddAssign, T: Into<ENU<N>>,

source§

fn add_assign(&mut self, right: T)

Performs the += operation. Read more
source§

impl<N: Clone> Clone for WGS84<N>

source§

fn clone(&self) -> WGS84<N>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<N: Debug> Debug for WGS84<N>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<N: RealFieldCopy> From<ECEF<N>> for WGS84<N>

source§

fn from(ecef: ECEF<N>) -> WGS84<N>

Converts to this type from the input type.
source§

impl<N: RealFieldCopy> From<NVector<N>> for WGS84<N>

source§

fn from(f: NVector<N>) -> WGS84<N>

Converts to this type from the input type.
source§

impl<N: RealFieldCopy> From<WGS84<N>> for ECEF<N>

source§

fn from(wgs: WGS84<N>) -> ECEF<N>

Converts to this type from the input type.
source§

impl<N: RealFieldCopy> From<WGS84<N>> for NVector<N>

source§

fn from(f: WGS84<N>) -> NVector<N>

Converts to this type from the input type.
source§

impl<N: PartialEq> PartialEq<WGS84<N>> for WGS84<N>

source§

fn eq(&self, other: &WGS84<N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N, T> Sub<T> for WGS84<N>where N: RealFieldCopy, T: Into<ENU<N>>,

§

type Output = WGS84<N>

The resulting type after applying the - operator.
source§

fn sub(self, right: T) -> WGS84<N>

Performs the - operation. Read more
source§

impl<N: RealFieldCopy> Sub<WGS84<N>> for WGS84<N>

§

type Output = ENU<N>

The resulting type after applying the - operator.
source§

fn sub(self, right: WGS84<N>) -> ENU<N>

Performs the - operation. Read more
source§

impl<N, T> SubAssign<T> for WGS84<N>where N: RealFieldCopy + SubAssign, T: Into<ENU<N>>,

source§

fn sub_assign(&mut self, right: T)

Performs the -= operation. Read more
source§

impl<N: Copy> Copy for WGS84<N>

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<T, Right> ClosedAdd<Right> for Twhere T: Add<Right, Output = T> + AddAssign<Right>,

§

impl<T, Right> ClosedSub<Right> for Twhere T: Sub<Right, Output = T> + SubAssign<Right>,

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,