You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "jiayuasu (via GitHub)" <gi...@apache.org> on 2023/08/02 20:57:19 UTC
[GitHub] [sedona] jiayuasu commented on a diff in pull request #942: [SEDONA-340] Add RS_ConvexHull | [SEDONA-341] Move RS_Envelope to Geometry Functions
jiayuasu commented on code in PR #942:
URL: https://github.com/apache/sedona/pull/942#discussion_r1282411858
##########
common/src/test/java/org/apache/sedona/common/raster/GeometryFunctionsTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.sedona.common.raster;
+
+import org.apache.sedona.common.Functions;
+import org.geotools.coverage.grid.GridCoverage2D;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.operation.TransformException;
+
+import java.io.IOException;
+
+public class GeometryFunctionsTest extends RasterTestBase {
+
+ @Test
+ public void testConvexHull() throws FactoryException, TransformException {
+ GridCoverage2D emptyRaster = RasterConstructors.makeEmptyRaster(1, 5, 10, 156, -132, 5);
+ Geometry convexHull = GeometryFunctions.convexHull(emptyRaster);
+ String expected = "POLYGON ((156 -132, 181 -132, 181 -182, 156 -182, 156 -132))";
+ String actual = Functions.asWKT(convexHull);
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testConvexHullSkewed() throws FactoryException, TransformException {
+ GridCoverage2D emptyRaster = RasterConstructors.makeEmptyRaster(1, 5, 10, 156, -132, 5, 10, 3, 5, 0);
+ Geometry convexHull = GeometryFunctions.convexHull(emptyRaster);
+ String expected = "POLYGON ((156 -132, 181 -107, 211 -7, 186 -32, 156 -132))";
+ String actual = Functions.asWKT(convexHull);
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testConvexHullFromRasterFile() throws FactoryException, TransformException, IOException {
+ GridCoverage2D raster = rasterFromGeoTiff(resourceFolder + "raster/test1.tiff");//RasterConstructors.makeEmptyRaster(1, 5, 10, 156, -132, 5, 10, 3, 5, 0);
Review Comment:
Remove the comment. Thanks.
##########
sql/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/raster/RasterAccessors.scala:
##########
@@ -18,12 +18,12 @@
*/
package org.apache.spark.sql.sedona_sql.expressions.raster
-import org.apache.sedona.common.raster.RasterAccessors
+import org.apache.sedona.common.raster.{GeometryFunctions, RasterAccessors}
import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.sedona_sql.expressions.InferrableFunctionConverter._
import org.apache.spark.sql.sedona_sql.expressions.InferredExpression
-case class RS_Envelope(inputExpressions: Seq[Expression]) extends InferredExpression(RasterAccessors.envelope _) {
+case class RS_Envelope(inputExpressions: Seq[Expression]) extends InferredExpression(GeometryFunctions.envelope _) {
Review Comment:
Please move this to GeometryFunction.scala as well.
--
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-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org