You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by GitBox <gi...@apache.org> on 2022/04/23 18:37:33 UTC
[GitHub] [incubator-sedona] jiayuasu commented on a diff in pull request #622: [SEDONA-115] Add ST_XMax and ST_XMin function
jiayuasu commented on code in PR #622:
URL: https://github.com/apache/incubator-sedona/pull/622#discussion_r857001027
##########
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:
Please carefully setup your IDE and carefully review your code submission. You are NOT supposed to change the format of the places that are NOT written by you.
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org