georust
2022-09-07 本文已影响0人
hehehehe
[package]
name = "poi_rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
geos = "8.1.0"
geo = "0.23.0"
wkt = "0.10.3"
// primitives
use geo::{line_string, polygon, Point};
// algorithms
use geo::ConvexHull;
use wkt::{ToWkt, TryFromWkt};
pub fn test_geo_fn() {
// An L shape
let poly = polygon![
(x: 0.0, y: 0.0),
(x: 4.0, y: 0.0),
(x: 4.0, y: 1.0),
(x: 1.0, y: 1.0),
(x: 1.0, y: 4.0),
(x: 0.0, y: 4.0),
(x: 0.0, y: 0.0),
];
// Calculate the polygon's convex hull
let hull = poly.convex_hull();
let wkt = hull.to_wkt();
println!("{}", wkt);
let point: Point<f64> = Point::try_from_wkt_str("POINT(10 20)").unwrap();
println!("{}", point.x().to_string());
}