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


##########
parquet-column/src/main/java/org/apache/parquet/column/statistics/geometry/EnvelopeCovering.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+import org.apache.parquet.Preconditions;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EnvelopeCovering extends Covering {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(EnvelopeCovering.class);
+
+  // The POC only supports EPSG:3857 and EPSG:4326 at the moment
+  private static final List<String> SUPPORTED_CRS = Arrays.asList("EPSG:3857", 
"EPSG:4326");
+
+  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();
+  private LogicalTypeAnnotation.Edges edges;
+  private String crs;
+
+  public EnvelopeCovering(LogicalTypeAnnotation.Edges edges, String crs) {
+    super(EMPTY, DEFAULT_COVERING_KIND);
+    this.edges = edges;
+    this.crs = crs;
+    validateSupportedCrs(this.crs);
+    validateKind(this.kind);
+  }
+
+  public EnvelopeCovering() {
+    super(EMPTY, DEFAULT_COVERING_KIND);
+  }
+
+  private static void validateKind(String kind) {
+    Preconditions.checkArgument(kind.equalsIgnoreCase(DEFAULT_COVERING_KIND), 
"kind only accepts WKB");
+  }
+
+  private static void validateSupportedCrs(String crs) {
+    if (!SUPPORTED_CRS.contains(crs)) {
+      LOG.warn("Unsupported CRS: {}. Supported CRS are EPSG:3857 and 
EPSG:4326.", crs);
+    }
+  }
+
+  @Override
+  public String getKind() {
+    return kind + "|" + crs + "|" + edges;
+  }
+
+  @Override
+  public void setKind(String kind) {
+    if (kind == null || kind.isEmpty()) {
+      throw new IllegalArgumentException("Kind cannot be null or empty");
+    }
+
+    // Split the input string by the "|" delimiter
+    String[] parts = kind.split("\\|");
+
+    // Ensure we have exactly 3 parts: kind, crs, and edges
+    if (parts.length != 3) {
+      throw new IllegalArgumentException("Invalid kind format. Expected 
format: 'kind|crs|edges'");
+    }
+
+    // Assign the values to the respective fields
+    this.kind = parts[0];
+    this.crs = parts[1];
+
+    try {
+      this.edges = LogicalTypeAnnotation.Edges.valueOf(parts[2]);
+    } catch (IllegalArgumentException e) {
+      throw new IllegalArgumentException("Invalid edges value: " + parts[2], 
e);
+    }
+  }
+
+  @Override
+  void update(Geometry geom) {

Review Comment:
   What is the difference between EnvelopeCovering and BBox stats when the edge 
== planar? I think they are the same. I thought we agreed that: when the edge = 
planar, we only generate BBox stats; when the edge = spherical, we generate 
both BBox and covering stats (but we omit the covering stats since we don't 
have the tool to calculate it).



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