diff --git a/lib/src/fnc/geo.rs b/lib/src/fnc/geo.rs index 69d4f508..2c49ed99 100644 --- a/lib/src/fnc/geo.rs +++ b/lib/src/fnc/geo.rs @@ -1,23 +1,25 @@ use crate::err::Error; use crate::sql::geometry::Geometry; use crate::sql::value::Value; -use geo::algorithm::area::Area; use geo::algorithm::bearing::Bearing; use geo::algorithm::centroid::Centroid; +use geo::algorithm::chamberlain_duquette_area::ChamberlainDuquetteArea; use geo::algorithm::haversine_distance::HaversineDistance; pub fn area((arg,): (Value,)) -> Result { match arg { Value::Geometry(v) => match v { - Geometry::Point(v) => Ok(v.signed_area().into()), - Geometry::Line(v) => Ok(v.signed_area().into()), - Geometry::Polygon(v) => Ok(v.signed_area().into()), - Geometry::MultiPoint(v) => Ok(v.signed_area().into()), - Geometry::MultiLine(v) => Ok(v.signed_area().into()), - Geometry::MultiPolygon(v) => Ok(v.signed_area().into()), - Geometry::Collection(v) => { - Ok(v.into_iter().collect::>().signed_area().into()) - } + Geometry::Point(v) => Ok(v.chamberlain_duquette_unsigned_area().into()), + Geometry::Line(v) => Ok(v.chamberlain_duquette_unsigned_area().into()), + Geometry::Polygon(v) => Ok(v.chamberlain_duquette_unsigned_area().into()), + Geometry::MultiPoint(v) => Ok(v.chamberlain_duquette_unsigned_area().into()), + Geometry::MultiLine(v) => Ok(v.chamberlain_duquette_unsigned_area().into()), + Geometry::MultiPolygon(v) => Ok(v.chamberlain_duquette_unsigned_area().into()), + Geometry::Collection(v) => Ok(v + .into_iter() + .collect::>() + .chamberlain_duquette_unsigned_area() + .into()), }, _ => Ok(Value::None), }