jiayuasu commented on code in PR #622:
URL: https://github.com/apache/incubator-sedona/pull/622#discussion_r857050030


##########
sql/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala:
##########
@@ -123,6 +123,69 @@ case class ST_YMin(inputExpressions: Seq[Expression])
     copy(inputExpressions = newChildren)
   }
 }
+
+/**
+ * Test if returning Max X coordinate value.
+ *
+ * @param inputExpressions
+ */
+case class ST_XMax(inputExpressions: Seq[Expression])
+  extends UnaryGeometryExpression with CodegenFallback {
+  assert(inputExpressions.length == 1)
+
+
+  override protected def nullSafeEval(geometry: Geometry): Any = {
+    var coord:Array[Coordinate] = geometry.getCoordinates()
+    var maxval = Double.MinValue
+    for (point<-coord) {
+      if(point.getX()>maxval){
+        maxval = point.getX()
+      }
+    }
+    maxval
+
+  }
+
+  override def dataType: DataType = DoubleType
+
+  override def children: Seq[Expression] = inputExpressions
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = 
{
+    copy(inputExpressions = newChildren)
+  }
+}
+
+/**
+ * Test if returning Min X coordinate value.
+ *
+ * @param inputExpressions
+ */
+case class ST_XMin(inputExpressions: Seq[Expression])
+  extends UnaryGeometryExpression with CodegenFallback {
+  assert(inputExpressions.length == 1)
+
+
+  override protected def nullSafeEval(geometry: Geometry): Any = {
+    var coord:Array[Coordinate] = geometry.getCoordinates()
+    var minval = Double.MaxValue
+    for (point<-coord) {
+      if(point.getX()<minval){
+        minval = point.getX()
+      }
+    }
+    minval
+
+  }
+
+  override def dataType: DataType = DoubleType
+
+  override def children: Seq[Expression] = inputExpressions
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = 
{
+    copy(inputExpressions = newChildren)
+  }
+}
+
 case class ST_3DDistance(inputExpressions: Seq[Expression])
   extends BinaryGeometryExpression with CodegenFallback {

Review Comment:
   @kvpankaj1999 Like I said, you should review the change you made via Git. 
GitHub also provides such an interface. You still changed other places. This is 
mostly because your IDE has some auto formatter.



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

Reply via email to