wgtmac commented on code in PR #2971:
URL: https://github.com/apache/parquet-java/pull/2971#discussion_r1707226608


##########
parquet-column/src/main/java/org/apache/parquet/column/statistics/geometry/EnvelopeCovering.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.parquet.column.statistics.geometry;
+
+import java.nio.ByteBuffer;
+import org.apache.parquet.schema.LogicalTypeAnnotation;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKBReader;
+import org.locationtech.jts.io.WKBWriter;
+
+public class EnvelopeCovering extends Covering {
+
+  private static final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[0]);
+  private final WKBReader reader = new WKBReader();
+  private final WKBWriter writer = new WKBWriter();
+  private final GeometryFactory factory = new GeometryFactory();
+
+  public EnvelopeCovering() {
+    super(EMPTY, LogicalTypeAnnotation.Edges.SPHERICAL);
+  }
+
+  @Override
+  void update(Geometry geom) {
+    if (geom == null) {
+      return;
+    }
+    try {
+      if (geometry != EMPTY) {
+        Geometry existingGeometry = reader.read(geometry.array());
+        Envelope existingEnvelope = existingGeometry.getEnvelopeInternal();
+        Envelope newEnvelope = geom.getEnvelopeInternal();
+
+        // The following expandToInclude method works correctly for planar 
coordinate systems.
+        // It simply extends the existing envelope to include the new envelope 
by adjusting
+        // the min and max values of x and y coordinates.
+        existingEnvelope.expandToInclude(newEnvelope);
+
+        // However, this approach is not accurate for spherical coordinate 
systems.

Review Comment:
   If this algorithm does not work for spherical geometry, should we throw when 
the logical type has set edges attribute to spherical?



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