Skip to content
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-182] ST_AsText should not return SRID #703

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ public static String asEWKT(Geometry geometry) {
return GeomUtils.getEWKT(geometry);
}

public static String asWKT(Geometry geometry) {
return GeomUtils.getWKT(geometry);
}

public static byte[] asEWKB(Geometry geometry) {
return GeomUtils.getEWKB(geometry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ public static String getEWKT(Geometry geometry) {
return sridString + new WKTWriter(GeomUtils.getDimension(geometry)).write(geometry);
}

public static String getWKT(Geometry geometry) {
if (geometry == null) {
return null;
}
return new WKTWriter(GeomUtils.getDimension(geometry)).write(geometry);
}

public static byte[] getEWKB(Geometry geometry) {
if (geometry == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ case class ST_PrecisionReduce(inputExpressions: Seq[Expression])
}

case class ST_AsText(inputExpressions: Seq[Expression])
extends InferredUnaryExpression(Functions.asEWKT) {
extends InferredUnaryExpression(Functions.asWKT) {

protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
copy(inputExpressions = newChildren)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ class functionTestScala extends TestBaseScala with Matchers with GeometrySample
polygonDf.createOrReplaceTempView("polygondf")
var wktDf = sparkSession.sql("select ST_AsText(countyshape) as wkt from polygondf")
assert(polygonDf.take(1)(0).getAs[Geometry]("countyshape").toText.equals(wktDf.take(1)(0).getAs[String]("wkt")))
val wkt = sparkSession.sql("select ST_AsText(ST_SetSRID(ST_Point(1.0,1.0), 3021))").first().getString(0)
assert(wkt == "POINT (1 1)", "WKT should not contain SRID")
}

it("Passed ST_AsText 3D") {
Expand Down