use geo::{ConvexHull, GeodesicArea};
use geo_types::{MultiPoint, Point, Polygon};
#[derive(Debug, Clone)]
pub struct HullResult {
pub hull: Polygon<f64>,
pub area_m2: f64,
pub area_km2: f64,
pub area_ha: f64,
pub perimeter_m: f64,
pub point_count: usize,
}
pub fn compute_convex_hull(points: &[Point<f64>]) -> HullResult {
let multi_point = MultiPoint::from(points.to_vec());
let hull = multi_point.convex_hull();
let area_m2 = hull.geodesic_area_unsigned();
let perimeter_m = hull.geodesic_perimeter();
HullResult {
hull,
area_m2,
area_km2: area_m2 / 1_000_000.0,
area_ha: area_m2 / 10_000.0,
perimeter_m,
point_count: points.len(),
}
}