szehon-ho commented on code in PR #54114:
URL: https://github.com/apache/spark/pull/54114#discussion_r2761587747


##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/geo/GeometryModel.java:
##########
@@ -176,4 +176,50 @@ GeometryCollection asGeometryCollection() {
     throw new ClassCastException(
       "Cannot cast " + getClass().getSimpleName() + " to GeometryCollection");
   }
+
+  /**
+   * Appends dimension suffix (Z, M, or ZM) to the WKT type name.
+   */
+  protected void appendDimensionSuffix(StringBuilder sb) {
+    if (hasZ && hasM) {
+      sb.append(" ZM");

Review Comment:
   nit: can we append " " earlier, to avoid repeating the empty string in all 
the string literals?



##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/geo/GeometryModel.java:
##########
@@ -176,4 +176,50 @@ GeometryCollection asGeometryCollection() {
     throw new ClassCastException(
       "Cannot cast " + getClass().getSimpleName() + " to GeometryCollection");
   }
+
+  /**
+   * Appends dimension suffix (Z, M, or ZM) to the WKT type name.
+   */
+  protected void appendDimensionSuffix(StringBuilder sb) {
+    if (hasZ && hasM) {
+      sb.append(" ZM");
+    } else if (hasZ) {
+      sb.append(" Z");
+    } else if (hasM) {
+      sb.append(" M");
+    }
+  }
+
+  /**
+   * Appends the WKT (Well-Known Text) representation of this geometry to the 
given StringBuilder.
+   */
+  protected void toWkt(StringBuilder sb) {
+    sb.append(typeId.getWktName());

Review Comment:
   same comment as above 



##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/geo/Point.java:
##########
@@ -98,4 +98,32 @@ boolean isEmpty() {
   int getDimensionCount() {
     return coordinates.length;
   }
+
+  @Override
+  protected void appendWktContent(StringBuilder sb) {
+    appendCoordinate(sb, getX());
+    sb.append(" ");
+    appendCoordinate(sb, getY());
+    if (hasZ) {
+      sb.append(" ");
+      appendCoordinate(sb, getZ());
+    }
+    if (hasM) {
+      sb.append(" ");
+      appendCoordinate(sb, getM());
+    }
+  }
+
+  /**
+   * Appends a single coordinate value, formatting integers without decimal 
point.
+   */
+  private static void appendCoordinate(StringBuilder sb, double value) {
+    if (value == Math.floor(value) && !Double.isInfinite(value)) {

Review Comment:
   how about value is NaN?
   
   Or if value = -0.0?
   
   I wonder these cases are valid?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to