This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new 7dbefc41 [SEDONA-204] Change Double.MIN_Value to -Double.MAX_Value 
(#726)
7dbefc41 is described below

commit 7dbefc411fa644132c8d37a33c29f771f3ccb0cf
Author: Jia Yu <[email protected]>
AuthorDate: Sun Dec 11 20:57:22 2022 -0800

    [SEDONA-204] Change Double.MIN_Value to -Double.MAX_Value (#726)
---
 common/src/main/java/org/apache/sedona/common/Functions.java |  8 ++++----
 .../org/apache/sedona/flink/expressions/Accumulators.java    |  8 ++++----
 .../test/scala/org/apache/sedona/sql/functionTestScala.scala | 12 +++++-------
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/common/src/main/java/org/apache/sedona/common/Functions.java 
b/common/src/main/java/org/apache/sedona/common/Functions.java
index 57abcd0c..5db853fa 100644
--- a/common/src/main/java/org/apache/sedona/common/Functions.java
+++ b/common/src/main/java/org/apache/sedona/common/Functions.java
@@ -130,7 +130,7 @@ public class Functions {
     
     public static double xMax(Geometry geometry) {
         Coordinate[] points = geometry.getCoordinates();
-        double max = Double.MIN_VALUE;
+        double max = - Double.MAX_VALUE;
         for (int i=0; i < points.length; i++) {
             max = Math.max(points[i].getX(), max);
         }
@@ -148,7 +148,7 @@ public class Functions {
     
     public static double yMax(Geometry geometry) {
         Coordinate[] points = geometry.getCoordinates();
-        double max = Double.MIN_VALUE;
+        double max = - Double.MAX_VALUE;
         for (int i=0; i < points.length; i++) {
             max = Math.max(points[i].getY(), max);
         }
@@ -157,13 +157,13 @@ public class Functions {
 
     public static Double zMax(Geometry geometry) {
         Coordinate[] points = geometry.getCoordinates();
-        double max = Double.MIN_VALUE;
+        double max = - Double.MAX_VALUE;
         for (int i=0; i < points.length; i++) {
             if(java.lang.Double.isNaN(points[i].getZ()))
                 continue;
             max = Math.max(points[i].getZ(), max);
         }
-        return max == Double.MIN_VALUE ? null : max;
+        return max == -Double.MAX_VALUE ? null : max;
     }
 
     public static Double zMin(Geometry geometry) {
diff --git 
a/flink/src/main/java/org/apache/sedona/flink/expressions/Accumulators.java 
b/flink/src/main/java/org/apache/sedona/flink/expressions/Accumulators.java
index fad05837..d331b4a7 100644
--- a/flink/src/main/java/org/apache/sedona/flink/expressions/Accumulators.java
+++ b/flink/src/main/java/org/apache/sedona/flink/expressions/Accumulators.java
@@ -24,13 +24,13 @@ public class Accumulators {
     public static class Envelope {
         public double minX = Double.MAX_VALUE;
         public double minY = Double.MAX_VALUE;
-        public double maxX = Double.MIN_VALUE;
-        public double maxY = Double.MIN_VALUE;
+        public double maxX = -Double.MAX_VALUE;
+        public double maxY = -Double.MAX_VALUE;
         void reset() {
             minX = Double.MAX_VALUE;
             minY = Double.MAX_VALUE;
-            maxX = Double.MIN_VALUE;
-            maxY = Double.MIN_VALUE;
+            maxX = -Double.MAX_VALUE;
+            maxY = -Double.MAX_VALUE;
         }
     }
     public static class AccGeometry {
diff --git a/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala 
b/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
index 5a28cdcc..f69a6de8 100644
--- a/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
+++ b/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
@@ -23,21 +23,19 @@ import org.apache.commons.codec.binary.Hex
 import org.apache.sedona.sql.implicits._
 import org.apache.spark.sql.functions._
 import org.apache.spark.sql.{DataFrame, Row}
+import org.geotools.referencing.CRS
 import org.locationtech.jts.algorithm.MinimumBoundingCircle
 import org.locationtech.jts.geom.{Geometry, Polygon}
 import org.locationtech.jts.io.WKTWriter
 import org.locationtech.jts.linearref.LengthIndexedLine
 import org.locationtech.jts.operation.distance3d.Distance3DOp
+import org.opengis.referencing.{FactoryException, NoSuchAuthorityCodeException}
 import org.scalatest.{GivenWhenThen, Matchers}
 import org.xml.sax.InputSource
-import java.io.StringReader
 
+import java.io.StringReader
 import javax.xml.parsers.DocumentBuilderFactory
 import javax.xml.xpath.XPathFactory
-import org.apache.sedona.sql.utils.GeometrySerializer
-import org.apache.spark.SparkException
-import org.geotools.referencing.CRS
-import org.opengis.referencing.{FactoryException, NoSuchAuthorityCodeException}
 
 class functionTestScala extends TestBaseScala with Matchers with 
GeometrySample with GivenWhenThen {
 
@@ -73,8 +71,8 @@ class functionTestScala extends TestBaseScala with Matchers 
with GeometrySample
     }
 
     it("Passed ST_YMax") {
-      var test = sparkSession.sql("SELECT ST_YMax(ST_GeomFromWKT('POLYGON ((-3 
-3, 3 -3, 3 3, -3 3, -3 -3))'))")
-      assert(test.take(1)(0).get(0).asInstanceOf[Double] == 3.0)
+      var test = sparkSession.sql("SELECT ST_YMax(ST_GeomFromWKT('POLYGON ((-3 
-3, 3 -3, 3 -2, -3 -1, -3 -3))'))")
+      assert(test.take(1)(0).get(0).asInstanceOf[Double] == -1)
     }
 
     it("Passed ST_YMin") {

Reply via email to