Struct transit_model::objects::Approx
source · pub struct Approx { /* private fields */ }
Expand description
Proxy object to compute approximate distances.
Implementations§
source§impl Approx
impl Approx
sourcepub fn sq_distance_to(&self, coord: &Coord) -> f64
pub fn sq_distance_to(&self, coord: &Coord) -> f64
Returns the squared distance to coord
. Squared distance is
returned to skip a sqrt
call, that is not important for
distance comparison or sorting.
Example
let v: Vec<Coord> = get_coords();
let from = Coord { lon: 2.37715, lat: 48.846_781 };
let one_km_squared = 1_000. * 1_000.;
let approx = from.approx();
for coord in &v {
if approx.sq_distance_to(coord) < one_km_squared {
println!("{:?} is within 1km", coord);
}
}
Auto Trait Implementations§
impl RefUnwindSafe for Approx
impl Send for Approx
impl Sync for Approx
impl Unpin for Approx
impl UnwindSafe for Approx
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