pub struct GeographicPoint { /* private fields */ }
Expand description
Represents a point using the geographic system of coordinates.
Implementations§
Source§impl GeographicPoint
impl GeographicPoint
pub fn new(longitude: f64, latitude: f64, altitude: f64) -> Self
Sourcepub fn from_cartesian(point: &CartesianPoint) -> Self
pub fn from_cartesian(point: &CartesianPoint) -> Self
Returns the equivalent GeographicPoint
of the given CartesianPoint
Sourcepub fn with_longitude(self, value: f64) -> Self
pub fn with_longitude(self, value: f64) -> Self
Calls set_longitude on self and returns it.
Sourcepub fn with_latitude(self, value: f64) -> Self
pub fn with_latitude(self, value: f64) -> Self
Calls set_latitude on self and returns it.
Sourcepub fn with_altitude(self, value: f64) -> Self
pub fn with_altitude(self, value: f64) -> Self
Calls set_altitude on self and returns it.
Sourcepub fn set_longitude(&mut self, value: f64)
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));
Sourcepub fn set_latitude(&mut self, value: f64)
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));
Sourcepub fn set_altitude(&mut self, value: f64)
pub fn set_altitude(&mut self, value: f64)
Sets the given altitude to the point.
Sourcepub fn long_ratio(&self) -> f64
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)
Sourcepub fn lat_ratio(&self) -> f64
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]
Sourcepub fn distance(&self, other: &GeographicPoint) -> f64
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
impl Clone for GeographicPoint
Source§fn clone(&self) -> GeographicPoint
fn clone(&self) -> GeographicPoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GeographicPoint
impl Debug for GeographicPoint
Source§impl Default for GeographicPoint
impl Default for GeographicPoint
Source§fn default() -> GeographicPoint
fn default() -> GeographicPoint
Source§impl From<CartesianPoint> for GeographicPoint
impl From<CartesianPoint> for GeographicPoint
Source§fn from(value: CartesianPoint) -> Self
fn from(value: CartesianPoint) -> Self
Source§impl From<GeographicPoint> for CartesianPoint
impl From<GeographicPoint> for CartesianPoint
Source§fn from(value: GeographicPoint) -> Self
fn from(value: GeographicPoint) -> Self
Source§impl From<GeographicPoint> for JsValue
impl From<GeographicPoint> for JsValue
Source§fn from(value: GeographicPoint) -> Self
fn from(value: GeographicPoint) -> Self
Source§impl FromWasmAbi for GeographicPoint
impl FromWasmAbi for GeographicPoint
Source§impl IntoWasmAbi for GeographicPoint
impl IntoWasmAbi for GeographicPoint
Source§impl LongRefFromWasmAbi for GeographicPoint
impl LongRefFromWasmAbi for GeographicPoint
Source§impl OptionFromWasmAbi for GeographicPoint
impl OptionFromWasmAbi for GeographicPoint
Source§impl OptionIntoWasmAbi for GeographicPoint
impl OptionIntoWasmAbi for GeographicPoint
Source§impl PartialEq for GeographicPoint
impl PartialEq for GeographicPoint
Source§impl RefFromWasmAbi for GeographicPoint
impl RefFromWasmAbi for GeographicPoint
Source§type Anchor = RcRef<GeographicPoint>
type Anchor = RcRef<GeographicPoint>
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§impl RefMutFromWasmAbi for GeographicPoint
impl RefMutFromWasmAbi for GeographicPoint
Source§impl TryFromJsValue for GeographicPoint
impl TryFromJsValue for GeographicPoint
Source§impl VectorFromWasmAbi for GeographicPoint
impl VectorFromWasmAbi for GeographicPoint
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[GeographicPoint]>
Source§impl VectorIntoJsValue for GeographicPoint
impl VectorIntoJsValue for GeographicPoint
fn vector_into_jsvalue(vector: Box<[GeographicPoint]>) -> JsValue
Source§impl VectorIntoWasmAbi for GeographicPoint
impl VectorIntoWasmAbi for GeographicPoint
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[GeographicPoint]>) -> Self::Abi
Source§impl WasmDescribeVector for GeographicPoint
impl WasmDescribeVector for GeographicPoint
impl Copy for GeographicPoint
impl StructuralPartialEq for GeographicPoint
impl SupportsConstructor for GeographicPoint
impl SupportsInstanceProperty for GeographicPoint
impl SupportsStaticProperty for GeographicPoint
Auto Trait Implementations§
impl Freeze for GeographicPoint
impl RefUnwindSafe for GeographicPoint
impl Send for GeographicPoint
impl Sync for GeographicPoint
impl Unpin for GeographicPoint
impl UnwindSafe for GeographicPoint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
Source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.