zhangfengcdt commented on code in PR #2971: URL: https://github.com/apache/parquet-java/pull/2971#discussion_r1947180036
########## 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()) { Review Comment: this is not relevant as well that kind is now removed from the final spec -- 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: issues-unsubscr...@parquet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@parquet.apache.org For additional commands, e-mail: issues-h...@parquet.apache.org