uros-db commented on code in PR #53227: URL: https://github.com/apache/spark/pull/53227#discussion_r2728658201
########## sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/geo/Ring.java: ########## @@ -0,0 +1,55 @@ +/* + * 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.spark.sql.catalyst.util.geo; + +import java.util.List; + +/** + * Represents a ring (closed linestring) in a polygon. + * + * In line with OGC standards, a ring must have at least 4 points, + * with the first and last point being identical to close the ring. + */ +class Ring { + private final List<Point> points; + + Ring(List<Point> points) { + this.points = points; + } + + List<Point> getPoints() { + return points; + } + + int getNumPoints() { + return points.size(); + } + + boolean isEmpty() { + return points.isEmpty(); + } + + boolean isClosed() { + if (points.size() < 4) { + return false; + } + Point first = points.get(0); + Point last = points.get(points.size() - 1); + return first.getX() == last.getX() && first.getY() == last.getY(); Review Comment: Here, we only compare X and Y for ring closure. But below in `WkbReader` (`private static boolean coordinatesEqual`) we seem to be comparing all coordinates: ``` private static boolean coordinatesEqual(double[] coords1, double[] coords2) { if (coords1.length != coords2.length) { return false; } for (int i = 0; i < coords1.length; i++) { if (coords1[i] != coords2[i]) { return false; } } return true; } ``` Is this intended? Are there test cases covering this (e.g. same XY but different Z/M, and various other similar combinations)? -- 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]
