Skip to content

feat(rust/sedona-functions): Implement ST_Force2D() and ST_Force3D()#606

Merged
paleolimbot merged 15 commits intoapache:mainfrom
yutannihilation:feat/st_force3d
Feb 13, 2026
Merged

feat(rust/sedona-functions): Implement ST_Force2D() and ST_Force3D()#606
paleolimbot merged 15 commits intoapache:mainfrom
yutannihilation:feat/st_force3d

Conversation

@yutannihilation
Copy link
Contributor

@yutannihilation yutannihilation commented Feb 12, 2026

Part of #554

This pull request enhances CrsTransform to change the number or types of dimensions by introducing these two changes

  • transform_coord_3d() takes the dimension of the input coordinate because otherwise there's no way to distinguish if the z value of coord is from the original input or is filled.
    • I think transform_coord() doesn't need this, but I'm not fully sure
  • new output_dim() returns the dimension of the output
pub trait CrsTransform: std::fmt::Debug {
    // same
    fn transform_coord(...) -> Result<(), SedonaGeometryError>;

    fn transform_coord_3d(
        &self,
        coord: &mut (f64, f64, f64),
        input_dims: Dimensions, // new
    ) -> Result<(), SedonaGeometryError>;

    // new
    fn output_dim(&self) -> Option<Dimensions>;
}

This pull request implements only ST_Force2D() and ST_Force3D(). In order to implement the variants related to M dimension, ST_Force3DM and ST_Force4D, probably CrsTransform needs to provide more methods that handles M dimension. But, probably these will be used only by ST_Force3DM and ST_Force4D, and I'm not sure if it's worth making the trait complex.

@yutannihilation yutannihilation marked this pull request as ready for review February 13, 2026 00:16
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! A few optional suggestions but also this is a huge improvement over the current situation as is.

and I'm not sure if it's worth making the trait complex.

I think it is, although feel free to file a follow-up ticket to track support of M values in transforms. M values are not heavily used although we (and PostGIS) have generally tried hard to make sure that we don't implement logic that can never extend to XYM geometries. We will probably have to make the trait more complex at some point anyway because the current version I don't think is all that performant in the context of huge arrays of coordinates.

Comment on lines +300 to +301
Some("POINT Z (3 4 5)"),
Some("POINT ZM (8 9 10 11)"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a POINT M work here?

Some("POINT EMPTY"),
Some("POINT Z EMPTY"),
Some("POINT (1 2)"),
Some("POINT Z (3 4 5)"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should POINT M work here?

Some("POINT EMPTY"),
Some("POINT (1 2)"),
Some("POINT Z (3 4 5)"),
Some("POINT (6 7)"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should POINT M work here?

yutannihilation and others added 4 commits February 13, 2026 20:40
@yutannihilation
Copy link
Contributor Author

I see, then I'll address the M dimension variants in another pull request.

feel free to file a follow-up ticket to track support of M values in transforms.

This pull request doesn't close #554, so I don't think another ticket is needed :)

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@paleolimbot paleolimbot changed the title Implement ST_Force2D() and ST_Force3D() feat(rust/sedona-functions): Implement ST_Force2D() and ST_Force3D() Feb 13, 2026
@paleolimbot paleolimbot merged commit d683122 into apache:main Feb 13, 2026
17 checks passed
@yutannihilation yutannihilation deleted the feat/st_force3d branch February 14, 2026 01:16
Copy link

@GalaxyA123 GalaxyA123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants