Struct GeographicPoint

Source
pub struct GeographicPoint { /* private fields */ }
Expand description

Represents a point using the geographic system of coordinates.

Implementations§

Source§

impl GeographicPoint

Source

pub fn new(longitude: f64, latitude: f64, altitude: f64) -> Self

Source

pub fn from_cartesian(point: &CartesianPoint) -> Self

Returns the equivalent GeographicPoint of the given CartesianPoint

Source

pub fn with_longitude(self, value: f64) -> Self

Calls set_longitude on self and returns it.

Source

pub fn with_latitude(self, value: f64) -> Self

Calls set_latitude on self and returns it.

Source

pub fn with_altitude(self, value: f64) -> Self

Calls set_altitude on self and returns it.

Source

pub fn set_longitude(&mut self, value: f64)

Sets the given longitude (in radiants) to the point.

§Definition

Since the longitude of a point on a sphere is the angle east (positive) or west (negative) in reference of the maridian zero, the longitude value must be in the range [-π, +π). Any other value will be recomputed in order to set its equivalent inside the range.

§Longitude adjustment

Both boundaries of the longitude range are consecutive, which means that overflowing one is the same as continuing from the other in the same direction.

§Example
use globe_rs::GeographicPoint;
use std::f64::consts::PI;
use float_cmp::approx_eq;

let mut point = GeographicPoint::default();
point.set_longitude(PI + 1_f64);

assert!(approx_eq!(f64, point.longitude(), -PI + 1_f64, ulps = 2));
Source

pub fn set_latitude(&mut self, value: f64)

Sets the given latitude (in radiants) to the point.

§Definition

Since the latitude of a point on a sphere is the angle between the equatorial plane and the straight line that passes through that point and through the center of the sphere, the latitude value must be in the range [-π/2, +π/2]. Any other value will be recomputed in order to set its equivalent inside the range. Notice that this action may recompute the longitude as well.

§Latitude adjustment

Overflowing any of both boundaries of the latitude range behaves like moving away from that point and getting closer to the oposite one.

§Longitude adjustment

Geometrically speaking, meridians are half of a circle going from the north pole to the south one. The position of each meridian in the perimeter of the sphere (horizontal axis) is set by the longitude itself. However, this value may change when the latitude overflows its normalized range. This happen since exceeding any of its established limits means moving from one to the other half of the circle on which the meridian is drawn. And therefore, the longitude gets increased by exactly π radiants.

Of course, this mutation on the longitude only applies when the overflow of the latitude is not enough to complete a full lap. If it is, the longitude does not change at all.

§Example
use globe_rs::GeographicPoint;
use std::f64::consts::PI;
use float_cmp::approx_eq;

let mut point = GeographicPoint::default();
point.set_latitude(-5. * PI / 4.);

assert!(approx_eq!(f64, point.latitude(), PI / 4., ulps = 2));
assert!(approx_eq!(f64, point.longitude(), -PI, ulps = 2));
Source

pub fn set_altitude(&mut self, value: f64)

Sets the given altitude to the point.

Source

pub fn longitude(&self) -> f64

Returns the longitude (in radiants) of the point.

Source

pub fn latitude(&self) -> f64

Returns the latitude (in radiants) of the point.

Source

pub fn altitude(&self) -> f64

Returns the altitude (in radiants) of the point.

Source

pub fn long_ratio(&self) -> f64

Returns the result of dividing π to the longitude of the point, resulting in a value in the range [-1.0, 1.0)

Source

pub fn lat_ratio(&self) -> f64

Returns the result of dividing π/2 to the latitude of the point, resulting in a value in the range [-1.0, 1.0]

Source

pub fn distance(&self, other: &GeographicPoint) -> f64

Computes the great-circle distance from self to the given point (in radiants).

Trait Implementations§

Source§

impl Clone for GeographicPoint

Source§

fn clone(&self) -> GeographicPoint

Returns a duplicate 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 Debug for GeographicPoint

Source§

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

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

impl Default for GeographicPoint

Source§

fn default() -> GeographicPoint

Returns the “default value” for a type. Read more
Source§

impl From<CartesianPoint> for GeographicPoint

Source§

fn from(value: CartesianPoint) -> Self

Converts to this type from the input type.
Source§

impl From<GeographicPoint> for CartesianPoint

Source§

fn from(value: GeographicPoint) -> Self

Converts to this type from the input type.
Source§

impl From<GeographicPoint> for JsValue

Source§

fn from(value: GeographicPoint) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for GeographicPoint

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for GeographicPoint

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for GeographicPoint

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<GeographicPoint>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for GeographicPoint

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for GeographicPoint

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl PartialEq for GeographicPoint

Source§

fn eq(&self, other: &GeographicPoint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefFromWasmAbi for GeographicPoint

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<GeographicPoint>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for GeographicPoint

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<GeographicPoint>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for GeographicPoint

Source§

type Error = JsValue

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

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl VectorFromWasmAbi for GeographicPoint

Source§

impl VectorIntoJsValue for GeographicPoint

Source§

impl VectorIntoWasmAbi for GeographicPoint

Source§

impl WasmDescribe for GeographicPoint

Source§

impl WasmDescribeVector for GeographicPoint

Source§

impl Copy for GeographicPoint

Source§

impl StructuralPartialEq for GeographicPoint

Source§

impl SupportsConstructor for GeographicPoint

Source§

impl SupportsInstanceProperty for GeographicPoint

Source§

impl SupportsStaticProperty for GeographicPoint

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

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

impl<T> ToOwned for T
where T: Clone,

Source§

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

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