rsgeo
rsgeo is a geography tool which is written with Rust.
Installation
Add it to your Cargo.toml
[dependencies]
rsgeo = "0.1.0"
Usage
Create two points with latitude and longitude,and get distance between two points
use *;
let p1 = new.unwrap;
let p2 = new.unwrap;
println!; //1740784.4
Get the degree from p1 to p2(the degree to north)
println!; //-82.38877
Create a Location
let p = new.unwrap;
let loc = new;
// a location is a point with a unix timestamp
Get the distance of location and point.
println!; //7237628.5
Get the speed of two locations
let loc1 = new;
let loc2 = new;
assert!; // m/s
Create Area and test if the point is in it.
let ra = new.unwrap;
let pa = new.unwrap;
let pb = new.unwrap;
assert!;
assert!;
let ca = new;
let pa = new.unwrap;
let pb = new.unwrap;
assert!;
assert!;
Create a polygon and test if the point is in it.
let pa = new.unwrap;
let pb = new.unwrap;
let pc = new.unwrap;
let pg = new;
assert!;
// polygon must have more than 3 points.The first point must be the same with the last point.
// the polygon can be convex or concave whatever
let pg = new;
assert_eq!;
let pt1 = new.unwrap;
let pt2 = new.unwrap;
assert!;
assert!;
Create a Trajectory
// A trajectory is a vector of some locations which must be chronological order.
let mut t = new;
let mut t = with_capacity; // like a vector
let loc1 = new;
let loc2 = new;
let loc3 = new;
t.push_location;
t.push_location;
t.push_location;
let mut t = from.unwrap; // or initialize with a slice of locations
Get the num of locations in Trajectory
assert_eq!;
Test if the trajectory passes area or polygon
let area1 = new.unwrap;
assert!;
Get the speed of a trajectory
let loc1 = new;
let loc2 = new;
let loc3 = new;
let mut t = with_capacity;
t.push_location;
t.push_location;
t.push_location;
assert!;
assert!;
Get the sum of distance of a trajectory
assert!;
Compare two trajectories and return the similarity of two trajectories.
use *;
use stlc_trajectory_similarity;
assert!;
// stlc is spatiotemporal linear combin distance
// the function returns similarity which is in (0,1]