-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SEDONA-237] Add ST_Dimension #867
Changes from 10 commits
6de6066
85528ea
f1c942b
63004bd
38f3bc1
ea78ebb
e189926
9a92eaa
5f7bff4
4d311c5
9e2d076
5388902
249228c
5cb89fc
c0636a4
f71688f
401aacc
3346376
7243ca5
d6ef412
05decc5
a2d82e5
4bc5ddc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,6 +400,20 @@ Result: | |
POLYGON ((0 -3, -3 -3, -3 3, 0 3, 0 -3)) | ||
``` | ||
|
||
## ST_Dimension | ||
|
||
Introduction: Return the topological dimension of this Geometry object, which must be less than or equal to the coordinate dimension. OGC SPEC s2.1.1.1 - returns 0 for POINT, 1 for LINESTRING, 2 for POLYGON, and the largest dimension of the components of a GEOMETRYCOLLECTION. If the dimension is unknown (e.g. for an empty GEOMETRYCOLLECTION) 0 is returned. | ||
|
||
Format: `ST_Dimension (A:geometry), ST_Dimension (C:geometrycolletion), ` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type in collection here |
||
|
||
Since: `v1.0.0` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide docs for Sedona Flink as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
Spark SQL example: | ||
```sql | ||
SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0))'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide the output of the example. In addition, have you tested other possible types, such as MultiPoint, MultiLineString, MultiPolygon. GeometryCollection can also have nested We are trying to provide consistent behavior as PostGIS. Please install PostGIS on your end and test the output in PostGIS as well. |
||
``` | ||
|
||
|
||
## ST_Distance | ||
|
||
Introduction: Return the Euclidean distance between A and B | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,18 @@ class functionTestScala extends TestBaseScala with Matchers with GeometrySample | |
assert(functionDf.count() > 0); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can follow the map way of specifying multiple test cases and their expected output here, it is more readable |
||
it("Passed ST_Dimension") { | ||
val test1 = sparkSession.sql("SELECT ST_Dimension(ST_GeomFromWKT('POINT(1 2)'))") | ||
assert(test1.take(1)(0).get(0).asInstanceOf[Int] == 0) | ||
val test2 = sparkSession.sql("SELECT ST_Dimension(ST_GeomFromWKT('LINESTRING(1 2, 3 4)'))") | ||
assert(test2.take(1)(0).get(0).asInstanceOf[Int] == 1) | ||
val test3 = sparkSession.sql("SELECT ST_Dimension(ST_GeomFromWKT('POLYGON((0 0,0 5,5 0,0 0))'))") | ||
assert(test3.take(1)(0).get(0).asInstanceOf[Int] == 2) | ||
val test4 = sparkSession.sql("SELECT ST_Dimension(ST_GeomFromWKT('GEOMETRYCOLLECTION EMPTY'))") | ||
assert(test4.take(1)(0).get(0).asInstanceOf[Int] == 0) | ||
val test5 = sparkSession.sql("SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0))')") | ||
assert(test5.take(1)(0).get(0).asInstanceOf[Int] == 1) | ||
} | ||
it("Passed ST_Distance") { | ||
var polygonWktDf = sparkSession.read.format("csv").option("delimiter", "\t").option("header", "false").load(mixedWktGeometryInputLocation) | ||
polygonWktDf.createOrReplaceTempView("polygontable") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please separate different testCases to different tests since these are unit tests.
You can have tests like dimensionGeom2D, dimensionGeomCollection, dimensionGeomEmpty, etc.
Also, use assertEquals(expected, actual) format so that the test failure flags expected and actual properly.
Additionally, please add test cases testing 3D geometry as well