You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "flomickl (via GitHub)" <gi...@apache.org> on 2023/03/03 23:00:35 UTC

[PR] 1353 geo create derived polygon of input geometry processor (streampipes)

flomickl opened a new pull request, #1380:
URL: https://github.com/apache/streampipes/pull/1380

   <!--
     ~ 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.
     ~
     -->
     
     <!--
   Thanks for contributing! Here are some tips you can follow to help us incorporate your contribution quickly and easily:
   1. If this is your first time, please read our contributor guidelines:
       - https://streampipes.apache.org/getinvolved.html
       - https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
   2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title ...`
   3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., `[WIP][#<GitHub issue id>] PR title ...`.
   4. Please write your PR title to summarize what this PR proposes/fixes.
   5. Link the PR to the corresponding GitHub issue (if present) in the `Development` section in the right menu bar. 
   6. Be sure to keep the PR description updated to reflect all changes.
   7. If possible, provide a concise example to reproduce the issue for a faster review.
   8. Make sure tests pass via `mvn clean install`.
   9. (Optional) If the contribution is large, please file an Apache ICLA
       - http://apache.org/licenses/icla.pdf
   -->
   
   ### Purpose
   New Geo Processor that creates bounding box or convex hull from other geometries
   
   ![derived](https://user-images.githubusercontent.com/16739072/222849957-9da5d33f-a3fa-4ca8-b001-4a419c361beb.png)
   
   
   ### Remarks
   <!--
   Is there anything left we need to pay attention on?
   Are there some references that might be important? E.g. links to Confluence, or discussions
   on the mailing list or GitHub.
   -->
   PR introduces (a) breaking change(s): no
   
   PR introduces (a) deprecation(s): no
   


-- 
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@streampipes.apache.org

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


Re: [PR] 1353 geo create derived polygon of input geometry processor (streampipes)

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #1380:
URL: https://github.com/apache/streampipes/pull/1380#discussion_r1125644722


##########
streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/polygon/CreateDerivedPolygonProcessor.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * 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.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.polygon;
+
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import org.apache.streampipes.extensions.management.monitoring.SpMonitoringManager;
+import org.apache.streampipes.model.DataProcessorType;
+import org.apache.streampipes.model.StreamPipesErrorMessage;
+import org.apache.streampipes.model.graph.DataProcessorDescription;
+import org.apache.streampipes.model.monitoring.SpLogEntry;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.processors.geo.jvm.jts.exceptions.SpNotSupportedGeometryException;
+import org.apache.streampipes.processors.geo.jvm.jts.helper.SpGeometryBuilder;
+import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
+import org.apache.streampipes.sdk.helpers.EpProperties;
+import org.apache.streampipes.sdk.helpers.EpRequirements;
+import org.apache.streampipes.sdk.helpers.Labels;
+import org.apache.streampipes.sdk.helpers.Locales;
+import org.apache.streampipes.sdk.helpers.Options;
+import org.apache.streampipes.sdk.helpers.OutputStrategies;
+import org.apache.streampipes.sdk.utils.Assets;
+import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.wrapper.routing.SpOutputCollector;
+import org.apache.streampipes.wrapper.standalone.ProcessorParams;
+import org.apache.streampipes.wrapper.standalone.StreamPipesDataProcessor;
+
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.Polygon;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CreateDerivedPolygonProcessor extends StreamPipesDataProcessor {
+  public static final String GEOM_KEY = "geometry-key";
+  public static final String EPSG_KEY = "epsg-key";
+  public static final String POLYGON_OUTPUT_TYPE_KEY = "polygon-output-type-key";
+  public static final String DERIVED_GEOM_KEY = "derived-point-geom-key";
+  public static final String DERIVED_EPSG_KEY = "derived-point-epsg-key";
+  public static final String DERIVED_GEOM_RUNTIME = "derived-polygon";
+  public static final String DERIVED_EPSG_RUNTIME = "epsg-derived-polygon";
+  private String geometryMapper;
+  private String epsgMapper;
+  private String outputType;
+  ProcessorParams params;
+  private static final Logger LOG = LoggerFactory.getLogger(CreateDerivedPolygonProcessor.class);
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder.create(
+            "org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.polygon")
+        .category(DataProcessorType.GEO)
+        .withAssets(Assets.DOCUMENTATION, Assets.ICON, "derivedPolygon.png")
+        .withLocales(Locales.EN)
+        .requiredStream(StreamRequirementsBuilder
+            .create()
+            .requiredPropertyWithUnaryMapping(
+                EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
+                Labels.withId(GEOM_KEY),
+                PropertyScope.MEASUREMENT_PROPERTY)
+            .requiredPropertyWithUnaryMapping(
+                EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
+                Labels.withId(EPSG_KEY),
+                PropertyScope.MEASUREMENT_PROPERTY)
+            .build())
+        .requiredSingleValueSelection(Labels.withId(POLYGON_OUTPUT_TYPE_KEY),
+            Options.from("Bounding Box", "Convex Hull"))
+        .outputStrategy(OutputStrategies.append(
+                EpProperties.stringEp(
+                    Labels.withId(DERIVED_GEOM_KEY),
+                    DERIVED_GEOM_RUNTIME,
+                    "http://www.opengis.net/ont/geosparql#Geometry"),
+                EpProperties.integerEp(
+                    Labels.withId(DERIVED_EPSG_KEY),
+                    DERIVED_EPSG_RUNTIME,
+                    "http://data.ign.fr/def/ignf#CartesianCS")
+            )
+        )
+        .build();
+  }
+
+  @Override
+  public void onInvocation(ProcessorParams parameters, SpOutputCollector spOutputCollector,
+                           EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException {
+
+    this.geometryMapper = parameters.extractor().mappingPropertyValue(GEOM_KEY);
+    this.epsgMapper = parameters.extractor().mappingPropertyValue(EPSG_KEY);
+    this.outputType = parameters.extractor().selectedSingleValue(POLYGON_OUTPUT_TYPE_KEY, String.class);
+    this.params = parameters;
+  }
+
+  @Override
+  public void onEvent(Event event, SpOutputCollector collector) throws SpRuntimeException {
+    String geom = event.getFieldBySelector(geometryMapper).getAsPrimitive().getAsString();
+    Integer epsg = event.getFieldBySelector(epsgMapper).getAsPrimitive().getAsInt();
+    Geometry geometry = SpGeometryBuilder.createSPGeom(geom, epsg);
+    if (geometry instanceof Point) {
+      SpMonitoringManager.INSTANCE.addErrorMessage(params.getGraph().getElementId(),
+          SpLogEntry.from(System.currentTimeMillis(),
+              StreamPipesErrorMessage.from(new SpNotSupportedGeometryException(
+                  "Point Geometry is not supported"))));
+    } else {
+      Polygon derivedPolygonOutput = null;
+      switch (this.outputType) {
+        case "Bounding Box":

Review Comment:
   Since you use these terms multiple times you can think of using a variable or defining an enum



-- 
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@streampipes.apache.org

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


Re: [PR] 1353 geo create derived polygon of input geometry processor (streampipes)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1380:
URL: https://github.com/apache/streampipes/pull/1380#issuecomment-1528407958

   Hello there :wave:<br> <br> We noticed that it's been some time since activity occurred on your pull request :thinking:. In order to keep things moving forward, we're marking this PR as _stale_ and giving you 7 days to respond before it's automatically closed :alarm_clock:.<br> <br> Please take a moment to review your pull request and make any necessary updates or changes :man_technologist:. If you need more time or have any questions, please don't hesitate to let us know :speech_balloon:.<br> <br> Thank you for your contributions to our project, and we look forward to hearing back from you soon :pray:.


-- 
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@streampipes.apache.org

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


Re: [PR] 1353 geo create derived polygon of input geometry processor (streampipes)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #1380: 1353 geo create derived polygon of input geometry processor
URL: https://github.com/apache/streampipes/pull/1380


-- 
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@streampipes.apache.org

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


Re: [PR] 1353 geo create derived polygon of input geometry processor (streampipes)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1380:
URL: https://github.com/apache/streampipes/pull/1380#issuecomment-1558346975

   Hello there :wave:<br> <br> We noticed that it's been some time since activity occurred on your pull request :thinking:. In order to keep things moving forward, we're marking this PR as _stale_ and giving you 7 days to respond before it's automatically closed :alarm_clock:.<br> <br> Please take a moment to review your pull request and make any necessary updates or changes :man_technologist:. If you need more time or have any questions, please don't hesitate to let us know :speech_balloon:.<br> <br> Thank you for your contributions to our project, and we look forward to hearing back from you soon :pray:.


-- 
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@streampipes.apache.org

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


Re: [PR] 1353 geo create derived polygon of input geometry processor (streampipes)

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #1380:
URL: https://github.com/apache/streampipes/pull/1380#discussion_r1125644932


##########
streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.polygon/documentation.md:
##########
@@ -0,0 +1,64 @@
+<!--
+  ~ 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.
+  ~
+  -->
+
+## Interior Point
+
+<p align="center">
+    <img src="icon.png" width="150px;" class="pe-image-documentation"/>
+</p>
+
+***
+
+## Description
+A single polygon geometry is derived from any geometry (except a
+point itself)
+
+***
+
+## Required inputs
+
+* JTS Geometry
+* EPSG Code
+* Polygon Output Type
+***
+
+## Configuration
+
+### Geometry field
+Input Geometry
+
+### EPSG field
+Integer value representing EPSG code
+
+### Point Output Type
+Chose between 
+* **Bounding Box:**  Gets a Geometry representing the bounding box of this geometry, whose vertices are 
+(minx miny, minx maxy, maxx maxy, maxx miny, minx miny).
+* **Convex Hull**: Computes the smallest convex Polygon that contains all the points in the Geometry.
+
+***
+
+## Output
+A polygon geometry with EPSG code.
+
+<p align="center">
+    <img src="derived_polygon.png.png" width="500;" class="pe-image-documentation"/>

Review Comment:
   As I cannot add comments to images: the image contains at least one German term `konvexe Hülle`



-- 
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@streampipes.apache.org

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


Re: [PR] 1353 geo create derived polygon of input geometry processor (streampipes)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1380:
URL: https://github.com/apache/streampipes/pull/1380#issuecomment-1567651231

   Hello there :wave:<br> <br> Unfortunately, we didn't hear back from you regarding your pull request, so we're closing it now. Don't worry, you can always reopen the PR at any time if you wish to continue working on it :raised_hands:.<br> <br> Please note that the branch associated with this pull request will not be deleted, so you can still access your changes and continue to work on them as needed :computer:.<br> <br> Thank you for your contributions to our project, and we hope to see you again soon!


-- 
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@streampipes.apache.org

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