Abeeujah commented on issue #303:
URL: https://github.com/apache/sedona-db/issues/303#issuecomment-3536946790
About this, I did start the implementation using `geo-traits` but then
stopped midway as I felt the overhead for going to andfrom `Geometry` to `Wkb`
to be able to call the `geos` `boundary` library function, to using
`geo-traits` convenience methods looks quite expensive serialising and
deserialising from one format to another (IMO), here's what it looked like
```rust
fn calculate_boundary_geos(geos_geom: &geos::Geometry) -> Result<Geometry> {
if geos_geom.geometry_type() == GeometryTypes::GeometryCollection {
let wkb_bytes = geos_geom.to_wkb().map_err(|e| {
DataFusionError::Execution(format!("Failed to convert to WKB:
{e}"))
})?;
let wkb = wkb::reader::read_wkb(wkb_bytes.as_ref()).map_err(|e| {
DataFusionError::Execution(format!("Failed to read WKB: {e}"))
})?;
let factory = GEOSWkbFactory::new();
match wkb.as_type() {
geo_traits::GeometryType::GeometryCollection(geometry_collection) => {
let boundaries: Result<Vec<_>> = geometry_collection
.geometries()
.map(|geom| {
let geos_geom = factory.create(geom).map_err(|e| {
DataFusionError::Execution(format!("Failed to
create GEOS geometry: {e}"))
})?;
calculate_boundary_geos(&geos_geom)
})
.collect();
Geometry::create_geometry_collection(boundaries?).map_err(|e| {
DataFusionError::Execution(format!("Failed to create
geometry collection: {e}"))
})
}
_ => unreachable!(),
}
} else {
geos_geom.boundary().map_err(|e| {
DataFusionError::Execution(format!("Failed to calculate
boundary: {e}"))
})
}
}
```
Another reason why I didn't continue that path was the amount of edge cases
I kept discovering along the line with the way `POSTGIS` computes the boundary
of a `GEOMETRYCOLLECTION`.
I currently base my implementations currently on the `geos` crate library
functions and as much info I can get from the POSTGIS reference - which is
mostly Consumer/User toned, not for developers building the said functions;
I would try to consult OGC Simple Feature Standards more, better still, It
would be great if you can recommend a more better resource I can consult and
work with
@paleolimbot @petern48 @jiayuasu
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]