Struct transit_model::objects::Coord
source · pub struct Coord {
pub lon: f64,
pub lat: f64,
}
Fields§
§lon: f64
§lat: f64
Implementations§
source§impl Coord
impl Coord
sourcepub fn distance_to(&self, other: &Self) -> f64
pub fn distance_to(&self, other: &Self) -> f64
Calculate the orthodromic distance in meters between 2 geographic coordinates
pub fn is_valid(&self) -> bool
sourcepub fn approx(&self) -> Approx
pub fn approx(&self) -> Approx
Returns a proxy object allowing to compute approximate distances for cheap computation.
Example
let v: Vec<Coord> = get_coords();
let from = Coord { lon: 2.37715, lat: 48.846_781 };
let approx = from.approx();
for coord in &v {
println!("distance({:?}, {:?}) = {}", from, coord, approx.sq_distance_to(coord).sqrt());
}
Trait Implementations§
source§impl<'de> Deserialize<'de> for Coord
impl<'de> Deserialize<'de> for Coord
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<Coord> for Coord
impl PartialEq<Coord> for Coord
impl Copy for Coord
impl StructuralPartialEq for Coord
Auto Trait Implementations§
impl RefUnwindSafe for Coord
impl Send for Coord
impl Sync for Coord
impl Unpin for Coord
impl UnwindSafe for Coord
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