LonLat

Struct LonLat 

Source
pub struct LonLat<M: Clone + Default = MValue>(pub VectorPoint<M>);
Expand description

§Longitude-Latitude Point container

§Description

This class represents a point on the unit sphere as a pair of latitude-longitude coordinates. Like the rest of the “geometry” package, the intent is to represent spherical geometry as a mathematical abstraction, so functions that are specifically related to the Earth’s geometry (e.g. easting/northing conversions) should be put elsewhere.

This struct implements the GetXY and GetM traits.

§Usage

Methods that are available:

Tuple Fields§

§0: VectorPoint<M>

Implementations§

Source§

impl<M: Clone + Default> LonLat<M>

Source

pub fn new(lon: f64, lat: f64, m: Option<M>) -> LonLat<M>

Build a new LonLat

Source

pub fn take(&mut self) -> VectorPoint<M>

Take the underlying VectorPoint

Source

pub fn lon(&self) -> f64

Return the longitude in degrees

Source

pub fn lat(&self) -> f64

Return the latitude in degrees

Source

pub fn from_s2cellid(cellid: S2CellId) -> Self

Convert a S2CellId to an LonLat

Source

pub fn from_s2_point(p: &S2Point) -> Self

Convert a direction vector (not necessarily unit length) to an LonLat.

Source

pub fn normalize(&mut self)

Normalize the coordinates to the range [-180, 180] and [-90, 90] deg.

Source

pub fn coords(self) -> (f64, f64)

Return the latitude or longitude coordinates in degrees.

Source

pub fn to_angles(&self) -> (S1Angle, S1Angle)

Return the latitude and longitude coordinates in radians.

Source

pub fn is_valid(&self) -> bool

Return true if the latitude is between -90 and 90 degrees inclusive and the longitude is between -180 and 180 degrees inclusive.

Source

pub fn to_point(&self) -> S2Point

Converts an LonLat to the equivalent unit-length vector. Unnormalized values (see Normalize()) are wrapped around the sphere as would be expected based on their definition as spherical angles. So for example the following pairs yield equivalent points (modulo numerical error): (90.5, 10) =~ (89.5, -170) (a, b) =~ (a + 360 * n, b) The maximum error in the result is 1.5 * DBL_EPSILON. (This does not include the error of converting degrees, E5, E6, or E7 to radians.)

Can be used just like an S2Point constructor. For example: S2Cap cap; cap.AddPoint(S2Point(latlon));

Source

pub fn to_point_gl(&self) -> S2Point

An alternative to to_point() that returns a GPU compatible vector.

Source

pub fn get_distance<M2: Clone + Default>(&self, b: &LonLat<M2>) -> f64

Returns the distance (measured along the surface of the sphere) to the given LonLat, implemented using the Haversine formula. This is equivalent to

S1Angle(ToPoint(), o.ToPoint())

except that this function is slightly faster, and is also somewhat less accurate for distances approaching 180 degrees (see s1angle.h for details). Both LngLats must be normalized.

Source

pub fn get_bearing<M2: Clone + Default>(&self, b: &LonLat<M2>) -> f64

Returns the bearing from the first point to the second point.

Trait Implementations§

Source§

impl<M1: Clone + Default, M2: Clone + Default> Add<LonLat<M2>> for LonLat<M1>

Source§

type Output = LonLat<M1>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: LonLat<M2>) -> Self::Output

Performs the + operation. Read more
Source§

impl<M: Clone + Default> BoxIndexAccessor for LonLat<M>

Source§

fn bbox(&self) -> BBox

Get the bounding box of the item
Source§

fn hilbert(&self, _index_bbox: &BBox) -> u64

Get the hilbert value of the item
Source§

impl<M: Clone + Clone + Default> Clone for LonLat<M>

Source§

fn clone(&self) -> LonLat<M>

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<M: Debug + Clone + Default> Debug for LonLat<M>

Source§

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

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

impl<M1: Clone + Default, M2: Clone + Default> Div<LonLat<M2>> for LonLat<M1>

Source§

type Output = LonLat<M1>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: LonLat<M2>) -> Self::Output

Performs the / operation. Read more
Source§

impl<M: Clone + Default> From<&LonLat<M>> for S2CellId

Source§

fn from(value: &LonLat<M>) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> From<&LonLat<M>> for S2Point

Source§

fn from(lonlat: &LonLat<M>) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> From<&S2Point> for LonLat<M>

Source§

fn from(p: &S2Point) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> From<S2CellId> for LonLat<M>

Source§

fn from(c: S2CellId) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> GetM<M> for LonLat<M>

Source§

fn m(&self) -> Option<&M>

Returns the m value
Source§

impl GetXY for LonLat

Source§

fn x(&self) -> f64

Returns the x value
Source§

fn y(&self) -> f64

Returns the y value
Source§

fn xy(&self) -> (f64, f64)

Returns the x and y values
Source§

impl<M1: Clone + Default, M2: Clone + Default> Mul<LonLat<M2>> for LonLat<M1>

Source§

type Output = LonLat<M1>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: LonLat<M2>) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for LonLat

Source§

type Output = LonLat

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl NewXY for LonLat

Source§

fn new_xy(x: f64, y: f64) -> LonLat

Create a new point with xy
Source§

impl Ord for LonLat

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<M: PartialEq + Clone + Default> PartialEq for LonLat<M>

Source§

fn eq(&self, other: &LonLat<M>) -> bool

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

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 PartialOrd for LonLat

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<M1: Clone + Default, M2: Clone + Default> Sub<LonLat<M2>> for LonLat<M1>

Source§

type Output = LonLat<M1>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: LonLat<M2>) -> Self::Output

Performs the - operation. Read more
Source§

impl Eq for LonLat

Source§

impl<M: Clone + Default> StructuralPartialEq for LonLat<M>

Auto Trait Implementations§

§

impl<M> Freeze for LonLat<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for LonLat<M>
where M: RefUnwindSafe,

§

impl<M> Send for LonLat<M>
where M: Send,

§

impl<M> Sync for LonLat<M>
where M: Sync,

§

impl<M> Unpin for LonLat<M>
where M: Unpin,

§

impl<M> UnwindSafe for LonLat<M>
where M: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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

§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, M> GetXYM<M> for T
where T: GetXY + GetM<M>,