Use Chamberlain Duquette geo algorithm to calculate geometry areas
The Chamberlain Duquette geo algorithm is now used to return the geodesic area of a SQL Geometry in meters squared. Closes #1414
This commit is contained in:
parent
4411b4d71f
commit
ed18003223
1 changed files with 12 additions and 10 deletions
|
@ -1,23 +1,25 @@
|
||||||
use crate::err::Error;
|
use crate::err::Error;
|
||||||
use crate::sql::geometry::Geometry;
|
use crate::sql::geometry::Geometry;
|
||||||
use crate::sql::value::Value;
|
use crate::sql::value::Value;
|
||||||
use geo::algorithm::area::Area;
|
|
||||||
use geo::algorithm::bearing::Bearing;
|
use geo::algorithm::bearing::Bearing;
|
||||||
use geo::algorithm::centroid::Centroid;
|
use geo::algorithm::centroid::Centroid;
|
||||||
|
use geo::algorithm::chamberlain_duquette_area::ChamberlainDuquetteArea;
|
||||||
use geo::algorithm::haversine_distance::HaversineDistance;
|
use geo::algorithm::haversine_distance::HaversineDistance;
|
||||||
|
|
||||||
pub fn area((arg,): (Value,)) -> Result<Value, Error> {
|
pub fn area((arg,): (Value,)) -> Result<Value, Error> {
|
||||||
match arg {
|
match arg {
|
||||||
Value::Geometry(v) => match v {
|
Value::Geometry(v) => match v {
|
||||||
Geometry::Point(v) => Ok(v.signed_area().into()),
|
Geometry::Point(v) => Ok(v.chamberlain_duquette_unsigned_area().into()),
|
||||||
Geometry::Line(v) => Ok(v.signed_area().into()),
|
Geometry::Line(v) => Ok(v.chamberlain_duquette_unsigned_area().into()),
|
||||||
Geometry::Polygon(v) => Ok(v.signed_area().into()),
|
Geometry::Polygon(v) => Ok(v.chamberlain_duquette_unsigned_area().into()),
|
||||||
Geometry::MultiPoint(v) => Ok(v.signed_area().into()),
|
Geometry::MultiPoint(v) => Ok(v.chamberlain_duquette_unsigned_area().into()),
|
||||||
Geometry::MultiLine(v) => Ok(v.signed_area().into()),
|
Geometry::MultiLine(v) => Ok(v.chamberlain_duquette_unsigned_area().into()),
|
||||||
Geometry::MultiPolygon(v) => Ok(v.signed_area().into()),
|
Geometry::MultiPolygon(v) => Ok(v.chamberlain_duquette_unsigned_area().into()),
|
||||||
Geometry::Collection(v) => {
|
Geometry::Collection(v) => Ok(v
|
||||||
Ok(v.into_iter().collect::<geo::Geometry<f64>>().signed_area().into())
|
.into_iter()
|
||||||
}
|
.collect::<geo::Geometry<f64>>()
|
||||||
|
.chamberlain_duquette_unsigned_area()
|
||||||
|
.into()),
|
||||||
},
|
},
|
||||||
_ => Ok(Value::None),
|
_ => Ok(Value::None),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue