You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "iGN5117 (via GitHub)" <gi...@apache.org> on 2023/08/02 20:46:51 UTC

[GitHub] [sedona] iGN5117 opened a new pull request, #942: [SEDONA-340] Add RS_ConvexHull | [SEDONA-341] Move RS_Envelope to Geometry Functions

iGN5117 opened a new pull request, #942:
URL: https://github.com/apache/sedona/pull/942

   
   ## Did you read the Contributor Guide?
   
   - Yes, I have read [Contributor Rules](https://sedona.apache.org/latest-snapshot/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest-snapshot/community/develop/)
   
   ## Is this PR related to a JIRA ticket?
   
   - Yes, the URL of the associated JIRA ticket is https://issues.apache.org/jira/browse/SEDONA-340 and https://issues.apache.org/jira/browse/SEDONA-341. The PR name follows the format `[SEDONA-XXX] my subject`.
   
   ## What changes were proposed in this PR?
   - Add RS_ConvexHull
   - Move RS_Envelope to Geometry Functions
   
   ## How was this patch tested?
   - Added new tests
   - Verified existing tests
   - Compiled documentation
   
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, I am adding a new API. I am using the [current SNAPSHOT version number](https://github.com/apache/sedona/blob/master/pom.xml#L29) in since `vX.Y.Z` format.
   


-- 
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: dev-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [sedona] iGN5117 commented on a diff in pull request #942: [SEDONA-340] Add RS_ConvexHull | [SEDONA-341] Move RS_Envelope to Geometry Functions

Posted by "iGN5117 (via GitHub)" <gi...@apache.org>.
iGN5117 commented on code in PR #942:
URL: https://github.com/apache/sedona/pull/942#discussion_r1282425111


##########
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:
   Done



##########
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:
   Moved



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


[GitHub] [sedona] jiayuasu commented on a diff in pull request #942: [SEDONA-340] Add RS_ConvexHull | [SEDONA-341] Move RS_Envelope to Geometry Functions

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
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


[GitHub] [sedona] jiayuasu merged pull request #942: [SEDONA-340] Add RS_ConvexHull | [SEDONA-341] Move RS_Envelope to Geometry Functions

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #942:
URL: https://github.com/apache/sedona/pull/942


-- 
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: dev-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org