diff --git a/docs/api/flink/Constructor.md b/docs/api/flink/Constructor.md index 0fa69ce8a3..7552cddcd5 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 1ed6398837..9dcb1938ca 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 d7732a876d..88ee33b667 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 static class ST_GeomFromWKT extends ScalarFunction { 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 static class ST_GeomFromText extends ScalarFunction { 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 e269d57410..e13f00d4d6 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 void testGeomFromWKT() { $(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 void testGeomFromText() { $(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