zhangfengcdt commented on code in PR #2849:
URL: https://github.com/apache/sedona/pull/2849#discussion_r3126575164
##########
common/src/main/java/org/apache/sedona/common/geography/Functions.java:
##########
@@ -85,6 +85,12 @@ public static int nPoints(Geography g) {
return toJTS(g).getNumPoints();
}
+ /** Return the WKT text representation of a geography. */
+ public static String asText(Geography g) {
+ if (g == null) return null;
+ return toJTS(g).toText();
Review Comment:
Good question! toJTS(g) on WKBGeography does one WKB → JTS parse and caches
the result in jtsGeometry (WKBGeography.java:116). Subsequent calls — both
later asText invocations on the same row and any other JTS-path function
(ST_NPoints, ST_GeometryType, ST_Centroid, ST_NumGeometries) — reuse the cached
Geometry for free.
The alternative — g.toString() on the Geography — actually goes through
WKBGeography.toString() getS2Geography().toString(), which populates the other
cache (s2Geography), so it's worse when the current implementation.
A true zero-parse path (WKB → WKT walker) would need custom code since JTS
doesn't expose it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]