yutannihilation commented on code in PR #504:
URL: https://github.com/apache/sedona-db/pull/504#discussion_r2688520319
##########
rust/sedona-geometry/src/transform.rs:
##########
@@ -58,13 +58,27 @@ pub trait CrsEngine: Debug {
/// Trait for transforming coordinates in a geometry from one CRS to another.
pub trait CrsTransform: std::fmt::Debug {
fn transform_coord(&self, coord: &mut (f64, f64)) -> Result<(),
SedonaGeometryError>;
+
+ // CrsTransform can optionally handle 3D coordinates. If this method is
not implemented,
+ // the Z coordinate is simply ignored.
+ fn transform_coord_3d(&self, coord: &mut (f64, f64, f64)) -> Result<(),
SedonaGeometryError> {
+ let mut coord_2d = (coord.0, coord.1);
+ self.transform_coord(&mut coord_2d)?;
+ coord.0 = coord_2d.0;
+ coord.1 = coord_2d.1;
+ Ok(())
+ }
}
/// A boxed trait object for dynamic dispatch of CRS transformations.
impl CrsTransform for Box<dyn CrsTransform> {
fn transform_coord(&self, coord: &mut (f64, f64)) -> Result<(),
SedonaGeometryError> {
self.as_ref().transform_coord(coord)
}
+
+ fn transform_coord_3d(&self, coord: &mut (f64, f64, f64)) -> Result<(),
SedonaGeometryError> {
+ self.as_ref().transform_coord_3d(coord)
+ }
Review Comment:
Thanks, I added some tests here.
--
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]