Struct rsgeo::prelude::Trajectory[][src]

pub struct Trajectory { /* fields omitted */ }

a trajectory is a vector of location which is in time-order

Implementations

impl Trajectory[src]

pub fn new() -> Self[src]

return a Trajectory object with no locations

pub fn with_capacity(capacity: usize) -> Self[src]

return a Trajectory object with capacity

pub fn from(locs: &[Location]) -> Result<Self, &'static str>[src]

pub fn push_location(&mut self, loc: &Location) -> Result<(), &'static str>[src]

add new locations to Trajectory

Example

use rsgeo::prelude::{Point,Location,Trajectory};
let loc1 = Location::new(Point::new(25.11,120.98).unwrap(),100);
let loc2 = Location::new(Point::new(26.2,121.1).unwrap(),150);
let loc3 = Location::new(Point::new(26.3,121.3).unwrap(),200);
let mut t = Trajectory::with_capacity(3);
t.push_location(&loc1);
t.push_location(&loc2);
t.push_location(&loc3);
assert_eq!(t.len(),3);
assert!(t.push_location(&Location::new(Point::new(26.5,121.4).unwrap(),190)).is_err()); // Invalid time order

pub fn len(&self) -> usize[src]

Returns the number of Locations in Trajectory

Example

use rsgeo::prelude::{Point,Location,Trajectory};
let loc1 = Location::new(Point::new(25.11,120.98).unwrap(),100);
let loc2 = Location::new(Point::new(26.2,121.1).unwrap(),150);
let loc3 = Location::new(Point::new(26.3,121.3).unwrap(),200);
let mut t = Trajectory::with_capacity(3);
t.push_location(&loc1);
t.push_location(&loc2);
t.push_location(&loc3);
assert_eq!(t.len(),3);

pub fn pass_rec_area(&self, area: &RecArea) -> bool[src]

judge if the trajectory passed rectangle area

The time complexity is (n),which n is the length of trajectory

Example

use rsgeo::prelude::{RecArea,Point,Trajectory,Location};
let loc1 = Location::new(Point::new(25.11,120.98).unwrap(),100);
let loc2 = Location::new(Point::new(26.2,121.1).unwrap(),150);
let loc3 = Location::new(Point::new(26.3,121.3).unwrap(),200);
let mut t = Trajectory::with_capacity(3);
t.push_location(&loc1);
t.push_location(&loc2);
t.push_location(&loc3);
let area1 = RecArea::new(35.07,35.12,111.9,112.0).unwrap();
let area2 = RecArea::new(26.15,26.201,120.0,121.15).unwrap();
assert!(!t.pass_rec_area(&area1));
assert!(t.pass_rec_area(&area2));

pub fn pass_circle_area(&self, area: &CircleArea) -> bool[src]

pub fn pass_polygon(&self, poly: &Polygon) -> bool[src]

pub fn max_speed(&self) -> Option<f32>[src]

Find the most fast speed of a trajectory

Time complexity is O(n),which n is the length of trajectory

Example

use rsgeo::prelude::{Point,Location,Trajectory};
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!((t.max_speed().unwrap() - 16.9352).abs() < 1e-3);

pub fn mean_speed(&self) -> Option<f32>[src]

Calculate the mean speed of trajectory.The trajectory

The time complexity is O(n),which n is the length of trajectory.

Example

use rsgeo::prelude::{Point,Location,Trajectory};
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!((t.mean_speed().unwrap() - 10.055225).abs() < 1e-6);

pub fn degrees(&self) -> Option<f32>[src]

return the sum of degree from a trajectory

Example

use rsgeo::prelude::*;
let loc1 = Location::new(Point::new(25.11,120.98).unwrap(),0);
let loc2 = Location::new(Point::new(25.11,121.1).unwrap(),7200);
let loc3 = Location::new(Point::new(25.11,121.3).unwrap(),14400);
let mut t = Trajectory::with_capacity(3);
t.push_location(&loc1);
t.push_location(&loc2);
t.push_location(&loc3);
assert!(t.degrees().unwrap().abs() < 1e-3);

pub fn is_empty(&self) -> bool[src]

Returns true if the trajectory contains no elements.

pub fn sum_distance(&self) -> f32[src]

pub fn sum_time(&self) -> u64[src]

Trait Implementations

impl Debug for Trajectory[src]

impl Default for Trajectory[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, 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.