This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch branch-1.6.1
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/branch-1.6.1 by this push:
new 4b9fb1d66 [SEDONA-643] [DOCS] Fix Flink constructor functions
signatures & remove redundant docs (#1549)
4b9fb1d66 is described below
commit 4b9fb1d669366fcfd2275407133ef76e3d8eab49
Author: Furqaan Khan <[email protected]>
AuthorDate: Thu Aug 15 14:54:45 2024 -0400
[SEDONA-643] [DOCS] Fix Flink constructor functions signatures & remove
redundant docs (#1549)
* add constructor function signatures to accept SRIDs, fix docs to add the
new signature and remove redundant docs
* fix spotless errors
---
docs/api/flink/Constructor.md | 52 ++++++----------------
docs/api/snowflake/vector-data/Constructor.md | 34 --------------
.../sedona/flink/expressions/Constructors.java | 14 ++++++
.../org/apache/sedona/flink/ConstructorTest.java | 24 ++++++++++
4 files changed, 52 insertions(+), 72 deletions(-)
diff --git a/docs/api/flink/Constructor.md b/docs/api/flink/Constructor.md
index 0fa69ce8a..7552cddcd 100644
--- a/docs/api/flink/Constructor.md
+++ b/docs/api/flink/Constructor.md
@@ -235,6 +235,8 @@ Introduction: Construct a Geometry from WKT. Alias of
[ST_GeomFromWKT](#st_geom
Format:
`ST_GeomFromText (Wkt: String)`
+`ST_GeomFromText (Wkt: String, srid: Integer)`
+
Since: `v1.2.1`
Example:
@@ -249,42 +251,6 @@ Output:
POINT(40.7128 -74.006)
```
-## ST_GeomFromEWKB
-
-Introduction: Construct a Geometry from EWKB string or Binary. This function
is an alias of [ST_GeomFromWKB](#st_geomfromwkb).
-
-Format:
-
-`ST_GeomFromEWKB (Wkb: String)`
-
-`ST_GeomFromEWKB (Wkb: Binary)`
-
-Since: `v1.6.1`
-
-SQL Example
-
-```sql
-SELECT ST_GeomFromEWKB([01 02 00 00 00 02 00 00 00 00 00 00 00 84 D6 00 C0 00
00 00 00 80 B5 D6 BF 00 00 00 60 E1 EF F7 BF 00 00 00 80 07 5D E5 BF])
-```
-
-Output:
-
-```
-LINESTRING (-2.1047439575195312 -0.354827880859375, -1.49606454372406
-0.6676061153411865)
-```
-
-SQL Example
-
-```sql
-SELECT
ST_asEWKT(ST_GeomFromEWKB('01010000a0e6100000000000000000f03f000000000000f03f000000000000f03f'))
-```
-
-Output:
-
-```
-SRID=4326;POINT Z(1 1 1)
-```
-
## ST_GeomFromWKB
Introduction: Construct a Geometry from WKB string or Binary. This function
also supports EWKB format.
@@ -340,6 +306,8 @@ Introduction: Construct a Geometry from WKT
Format:
`ST_GeomFromWKT (Wkt: String)`
+`ST_GeomFromWKT (Wkt: String, srid: Integer)`
+
Since: `v1.2.0`
Example:
@@ -484,7 +452,11 @@ LINESTRING (-2.1047439575195312 -0.354827880859375,
-1.49606454372406 -0.6676061
Introduction: Construct a MultiLineString from Text and Optional SRID
-Format: `ST_MLineFromText (Text: String, Srid: Integer)`
+Format:
+
+`ST_MLineFromText (Wkt: String)`
+
+`ST_MLineFromText (Wkt: String, Srid: Integer)`
Since: `1.3.1`
@@ -528,7 +500,11 @@ MULTIPOINT ((10 10), (20 20), (30 30))
Introduction: Construct a MultiPolygon from Text and Optional SRID
-Format: `ST_MPolyFromText (Text: String, Srid: Integer)`
+Format:
+
+`ST_MPolyFromText (Wkt: String)`
+
+`ST_MPolyFromText (Wkt: String, Srid: Integer)`
Since: `1.3.1`
diff --git a/docs/api/snowflake/vector-data/Constructor.md
b/docs/api/snowflake/vector-data/Constructor.md
index 1ed639883..9dcb1938c 100644
--- a/docs/api/snowflake/vector-data/Constructor.md
+++ b/docs/api/snowflake/vector-data/Constructor.md
@@ -237,40 +237,6 @@ Output:
POINT(40.7128 -74.006)
```
-## ST_GeomFromEWKB
-
-Introduction: Construct a Geometry from EWKB string or Binary. This function
is an alias of [ST_GeomFromWKB](#st_geomfromwkb).
-
-Format:
-
-`ST_GeomFromEWKB (Wkb: String)`
-
-`ST_GeomFromEWKB (Wkb: Binary)`
-
-SQL Example
-
-```sql
-SELECT ST_GeomFromEWKB([01 02 00 00 00 02 00 00 00 00 00 00 00 84 D6 00 C0 00
00 00 00 80 B5 D6 BF 00 00 00 60 E1 EF F7 BF 00 00 00 80 07 5D E5 BF])
-```
-
-Output:
-
-```
-LINESTRING (-2.1047439575195312 -0.354827880859375, -1.49606454372406
-0.6676061153411865)
-```
-
-SQL Example
-
-```sql
-SELECT
ST_asEWKT(ST_GeomFromEWKB('01010000a0e6100000000000000000f03f000000000000f03f000000000000f03f'))
-```
-
-Output:
-
-```
-SRID=4326;POINT Z(1 1 1)
-```
-
## ST_GeomFromWKB
Introduction: Construct a Geometry from WKB string or Binary. This function
also supports EWKB format.
diff --git
a/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
b/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
index d7732a876..88ee33b66 100644
--- a/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
+++ b/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
@@ -241,6 +241,13 @@ public class Constructors {
public Geometry eval(@DataTypeHint("String") String wktString) throws
ParseException {
return org.apache.sedona.common.Constructors.geomFromWKT(wktString, 0);
}
+
+ @DataTypeHint(value = "RAW", bridgedTo =
org.locationtech.jts.geom.Geometry.class)
+ public Geometry eval(
+ @DataTypeHint("String") String wktString, @DataTypeHint("Int") Integer
srid)
+ throws ParseException {
+ return org.apache.sedona.common.Constructors.geomFromWKT(wktString,
srid);
+ }
}
public static class ST_GeomFromEWKT extends ScalarFunction {
@@ -269,6 +276,13 @@ public class Constructors {
public Geometry eval(@DataTypeHint("String") String wktString) throws
ParseException {
return org.apache.sedona.common.Constructors.geomFromWKT(wktString, 0);
}
+
+ @DataTypeHint(value = "RAW", bridgedTo =
org.locationtech.jts.geom.Geometry.class)
+ public Geometry eval(
+ @DataTypeHint("String") String wktString, @DataTypeHint("Int") Integer
srid)
+ throws ParseException {
+ return org.apache.sedona.common.Constructors.geomFromWKT(wktString,
srid);
+ }
}
public static class ST_GeomFromWKB extends ScalarFunction {
diff --git a/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
b/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
index e269d5741..e13f00d4d 100644
--- a/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
+++ b/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
@@ -287,6 +287,18 @@ public class ConstructorTest extends TestBase {
$(polygonColNames[1]));
Row result = last(geomTable);
assertEquals(data.get(data.size() - 1).getField(0).toString(),
result.getField(0).toString());
+
+ geomTable =
+ wktTable.select(
+ call(Constructors.ST_GeomFromWKT.class.getSimpleName(),
$(polygonColNames[0]), 1111)
+ .as(polygonColNames[0]),
+ $(polygonColNames[1]));
+ int sridActual =
+ (int)
+ last(geomTable.select(
+ call(Functions.ST_SRID.class.getSimpleName(),
$(polygonColNames[0]))))
+ .getField(0);
+ assertEquals(1111, sridActual);
}
@Test
@@ -316,6 +328,18 @@ public class ConstructorTest extends TestBase {
$(polygonColNames[1]));
Row result = last(geomTable);
assertEquals(data.get(data.size() - 1).getField(0).toString(),
result.getField(0).toString());
+
+ geomTable =
+ wktTable.select(
+ call(Constructors.ST_GeomFromText.class.getSimpleName(),
$(polygonColNames[0]), 1111)
+ .as(polygonColNames[0]),
+ $(polygonColNames[1]));
+ int sridActual =
+ (int)
+ last(geomTable.select(
+ call(Functions.ST_SRID.class.getSimpleName(),
$(polygonColNames[0]))))
+ .getField(0);
+ assertEquals(1111, sridActual);
}
@Test