pub struct Position {
pub lat: f64,
pub lng: f64,
}
Expand description
A struct to represent a position on the map.
This allows to pass the positions around even on the server side, since LatLng is a client-side only struct.
This struct offers some utility methods to work with positions, and conversions to LatLng. It also supports passing positions as tuples or arrays.
Fields§
§lat: f64
§lng: f64
Implementations§
Source§impl Position
impl Position
Sourcepub fn distance_haversine(&self, other: &Self) -> f64
pub fn distance_haversine(&self, other: &Self) -> f64
Determines the distance between two positions using the Haversine formula.
The result is in meters
Sourcepub fn inside_circle(&self, center: &Position, radius: f64) -> bool
pub fn inside_circle(&self, center: &Position, radius: f64) -> bool
Checks if the position is inside a circle
§Arguments
center
: Center of the circleradius
: Radius of the circle in meters
returns: bool
Sourcepub fn inside_polygon(&self, polygon: &[Position]) -> bool
pub fn inside_polygon(&self, polygon: &[Position]) -> bool
Check if the position is inside a polygon
Sourcepub fn distance(&self, other: &Self) -> f64
pub fn distance(&self, other: &Self) -> f64
Distance between two positions using pytagore theorem
pub fn as_lat_lng(&self) -> LatLng
Trait Implementations§
Source§impl IntoLatLng for Position
impl IntoLatLng for Position
fn into_lat_lng(self) -> LatLng
impl Copy for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.