Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yyy1000
Copy link
Contributor

@yyy1000 yyy1000 commented Aug 10, 2023

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

GetDimension will support 2D and 3D, which will lead functions like ST_AsWKT ignore the M coordinate. After this PR is merged, M coordinate will be available in WKT format.

In short, current status of Sedona Input and Output ST functions are follows:

  1. ST_AsEWKT: SRID + XYZM WKT
  2. ST_AsText: XYZM WKT
  3. ST_GeomFromWKT: accepts EWKT and WKT format, with XYZM
  4. ST_GeomFromWKB: accepts EWKB format, with XYZM but M is ignored.
  5. ST_AsWKB will print EWKB without M

Sedona Jvm serializer will carry XYZM + SRID. So any ST functions in Sedona can access XYZM in the geometry type.
Shapely serializer does not support M so when deal with data created by Shapely, M is ignored.

How was this patch tested?

Comprehensive unit tests in sedona-common

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation update.


public static int getDimension(Geometry geometry) {
return geometry.getCoordinate() != null && !java.lang.Double.isNaN(geometry.getCoordinate().getZ()) ? 3 : 2;
int dimension = 2;
Copy link
Member

Choose a reason for hiding this comment

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

This function is duplicate to nDims(): https://github.com/apache/sedona/blob/master/common/src/main/java/org/apache/sedona/common/Functions.java#L298

Please copy the logic of nDims here and let nDims function call this getDimension function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

@jiayuasu jiayuasu added this to the sedona-1.5.0 milestone Aug 10, 2023
@jiayuasu jiayuasu changed the title [SEDONA-348] Support 4D Geometry in getDimension [SEDONA-351] Support XYZM coordinate Aug 10, 2023
@Test
public void asEWKT() throws Exception{
Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
String actualResult = Functions.asEWKT(geometry);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the test cases for EWKT have SRID too? @yyy1000 @jiayuasu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea.
I added SRID in them.

@jiayuasu jiayuasu merged commit 2754997 into apache:master Aug 11, 2023
@jiayuasu jiayuasu deleted the fix-dimension branch August 11, 2023 01:09
Kontinuation pushed a commit to Kontinuation/sedona that referenced this pull request Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants