Struct rsgeo::prelude::Location[][src]

pub struct Location { /* fields omitted */ }

Location is a Point with unix timestamp

Implementations

impl Location[src]

pub fn new(pos: Point, timestamp: u64) -> Self[src]

Example

use rsgeo::prelude::{Point,Location};
let p = Point::new(35.12,46.15).unwrap();
let loc = Location::new(p,123);

pub fn distance(&self, other: &Self) -> f32[src]

calculate distance between location and location

pub fn distance_from_point(&self, other: &Point) -> f32[src]

calculate distance between location and Point

pub fn distance_from_trajectory(&self, other: &Trajectory) -> Option<f32>[src]

calculate distance between location and Trajectory

pub fn speed(&self, other: &Self) -> f32[src]

calculate speed between two locations,return m/s

Example

use rsgeo::prelude::{Point,Location};
let loc1 = Location::new(Point::new(25.12,110.15).unwrap(),100);
let loc2 = Location::new(Point::new(25.119,109.995).unwrap(),3700);
assert!(loc1.speed(&loc2) - 4.3396673 < 1e-6);

pub fn time_shortest_distance_from_trajectory(
    &self,
    other: &Trajectory
) -> Option<u64>
[src]

return the shortest time distance from trajectory

Example

use rsgeo::prelude::*;
let loc = Location::new(Point::new(25.12,110.15).unwrap(),100);
let loc1 = Location::new(Point::new(25.11,120.98).unwrap(),0);
let loc2 = Location::new(Point::new(26.2,121.1).unwrap(),7200);
let loc3 = Location::new(Point::new(26.3,121.3).unwrap(),14400);
let mut t = Trajectory::with_capacity(3);
t.push_location(&loc1);
t.push_location(&loc2);
t.push_location(&loc3);
assert_eq!(loc.time_shortest_distance_from_trajectory(&t).unwrap(),100);

pub fn degree(&self, other: &Location) -> f32[src]

Trait Implementations

impl Clone for Location[src]

impl Copy for Location[src]

impl Debug for Location[src]

impl Eq for Location[src]

impl PartialEq<Location> for Location[src]

impl StructuralEq for Location[src]

impl StructuralPartialEq for Location[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.