dongjoon-hyun commented on code in PR #2032:
URL: https://github.com/apache/orc/pull/2032#discussion_r2134888942


##########
java/core/src/java/org/apache/orc/geospatial/BoundingBox.java:
##########
@@ -0,0 +1,374 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.orc.geospatial;
+
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ * Bounding box for Geometry or Geography type in the representation of min/max
+ * value pairs of coordinates from each axis.
+ * A bounding box is considered valid if none of the X / Y dimensions contain 
NaN.
+ */
+public class BoundingBox {
+
+  private double xMin = Double.POSITIVE_INFINITY;
+  private double xMax = Double.NEGATIVE_INFINITY;
+  private double yMin = Double.POSITIVE_INFINITY;
+  private double yMax = Double.NEGATIVE_INFINITY;
+  private double zMin = Double.POSITIVE_INFINITY;
+  private double zMax = Double.NEGATIVE_INFINITY;
+  private double mMin = Double.POSITIVE_INFINITY;
+  private double mMax = Double.NEGATIVE_INFINITY;
+  private boolean valid = true;
+
+  public BoundingBox() {
+  }
+
+  public BoundingBox(
+          double xMin, double xMax, double yMin, double yMax,
+          double zMin, double zMax, double mMin, double mMax) {
+    this.xMin = xMin;
+    this.xMax = xMax;
+    this.yMin = yMin;
+    this.yMax = yMax;
+    this.zMin = zMin;
+    this.zMax = zMax;
+    this.mMin = mMin;
+    this.mMax = mMax;
+
+    // Update the validity
+    valid = isXYValid();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (!(obj instanceof BoundingBox other)) {
+      return false;
+    }
+    if (obj == this) {
+      return true;
+    }
+    return xMin == other.xMin && xMax == other.xMax && yMin == other.yMin && 
yMax == other.yMax &&
+           zMin == other.zMin && zMax == other.zMax && mMin == other.mMin && 
mMax == other.mMax;
+  }
+
+  @Override
+  public int hashCode() {
+    return Double.hashCode(xMin) ^ Double.hashCode(xMax) ^
+           Double.hashCode(yMin) ^ Double.hashCode(yMax) ^
+           Double.hashCode(zMin) ^ Double.hashCode(zMax) ^
+           Double.hashCode(mMin) ^ Double.hashCode(mMax);
+  }
+
+  private void resetBBox() {
+    xMin = Double.POSITIVE_INFINITY;
+    xMax = Double.NEGATIVE_INFINITY;
+    yMin = Double.POSITIVE_INFINITY;
+    yMax = Double.NEGATIVE_INFINITY;
+    zMin = Double.POSITIVE_INFINITY;
+    zMax = Double.NEGATIVE_INFINITY;
+    mMin = Double.POSITIVE_INFINITY;
+    mMax = Double.NEGATIVE_INFINITY;
+
+    // Update the validity
+    valid = isXYValid();

Review Comment:
   In theory, this is always `true`, right?
   ```
   $ jshell
   |  Welcome to JShell -- Version 24.0.1
   |  For an introduction type: /help intro
   
   jshell> Double.isNaN(Double.POSITIVE_INFINITY)
   $1 ==> false
   ```



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