You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by mi...@apache.org on 2023/02/24 19:08:29 UTC
[streampipes] branch 1321-geo-create-derived-point-of-input-geometry-processor updated (7b693a2fd -> 6a00daffa)
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a change to branch 1321-geo-create-derived-point-of-input-geometry-processor
in repository https://gitbox.apache.org/repos/asf/streampipes.git
from 7b693a2fd Update data stream generator (#1258) (#1286)
new 6f3a0df7f [#1321] first base setup and add resources
new 0a9adbf9a [#1321] add switch between interior and centroid point as output. add resources
new 6a00daffa [#1321] extend documentary. Add log output to log field
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../streampipes/processors/geo/jvm/GeoJvmInit.java | 4 +-
.../point/CreateDerivedPointProcessor.java} | 124 ++++++++++-----------
.../derivedPoint.png | Bin 0 -> 47994 bytes
.../documentation.md | 43 +++----
.../icon.png | Bin 0 -> 16877 bytes
.../strings.en | 14 ++-
6 files changed, 93 insertions(+), 92 deletions(-)
copy streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/{reprojection/ReprojectionProcessor.java => derivedgeometry/point/CreateDerivedPointProcessor.java} (52%)
create mode 100644 streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/derivedPoint.png
copy streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/{org.apache.streampipes.processors.geo.jvm.latlong.processor.revgeocoder.geocityname => org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point}/documentation.md (56%)
mode change 100644 => 100755
create mode 100644 streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/icon.png
copy streampipes-extensions/{streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.adapters.simulator.machine => streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point}/strings.en (62%)
mode change 100644 => 100755
[streampipes] 03/03: [#1321] extend documentary. Add log output to log field
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a commit to branch 1321-geo-create-derived-point-of-input-geometry-processor
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 6a00daffa45ecd0c63b52a1fcfd09f6798895695
Author: micklich <mi...@apache.org>
AuthorDate: Fri Feb 24 20:08:05 2023 +0100
[#1321] extend documentary. Add log output to log field
---
.../point/CreateDerivedPointProcessor.java | 19 +++++++++++++------
.../derivedPoint.png | Bin 0 -> 47994 bytes
.../documentation.md | 13 ++++++++-----
3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java
index 0113cc08a..28914559a 100644
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java
@@ -19,10 +19,14 @@
package org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point;
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;
@@ -54,6 +58,7 @@ public class CreateDerivedPointProcessor extends StreamPipesDataProcessor {
private String geometryMapper;
private String epsgMapper;
private String outputType;
+ ProcessorParams params;
private static final Logger LOG = LoggerFactory.getLogger(CreateDerivedPointProcessor.class);
@Override
@@ -61,7 +66,7 @@ public class CreateDerivedPointProcessor extends StreamPipesDataProcessor {
return ProcessingElementBuilder.create(
"org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point")
.category(DataProcessorType.GEO)
- .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+ .withAssets(Assets.DOCUMENTATION, Assets.ICON, "derivedPoint.png")
.withLocales(Locales.EN)
.requiredStream(StreamRequirementsBuilder
.create()
@@ -97,17 +102,19 @@ public class CreateDerivedPointProcessor extends StreamPipesDataProcessor {
this.geometryMapper = parameters.extractor().mappingPropertyValue(GEOM_KEY);
this.epsgMapper = parameters.extractor().mappingPropertyValue(EPSG_KEY);
this.outputType = parameters.extractor().selectedSingleValue(POINT_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 sourceEpsg = event.getFieldBySelector(epsgMapper).getAsPrimitive().getAsInt();
- Geometry geometry = SpGeometryBuilder.createSPGeom(geom, sourceEpsg);
+ Integer epsg = event.getFieldBySelector(epsgMapper).getAsPrimitive().getAsInt();
+ Geometry geometry = SpGeometryBuilder.createSPGeom(geom, epsg);
if (geometry instanceof Point) {
- // TODO remove check after harmonized semantic types and multiple tpes
- LOG.debug("geom is already a point");
+ SpMonitoringManager.INSTANCE.addErrorMessage(params.getGraph().getElementId(),
+ SpLogEntry.from(System.currentTimeMillis(),
+ StreamPipesErrorMessage.from(new SpNotSupportedGeometryException(
+ "Point Geometry is not supported"))));
} else {
Point derivedPointOutput = null;
switch (this.outputType) {
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/derivedPoint.png b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/derivedPoint.png
new file mode 100644
index 000000000..46270393c
Binary files /dev/null and b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/derivedPoint.png differ
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md
index 6f9322a2a..de66b2565 100755
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md
@@ -25,7 +25,8 @@
***
## Description
-Creates a Point of every other Geometry (not included a Point itself).
+A single point geometry is derived from any geometry (except a
+point itself)
***
@@ -46,12 +47,11 @@ Integer value representing EPSG code
### Point Output Type
Chose between
-* Interior Point
- * An interior point is guaranteed to lie in the interior of the Geometry,
+* **Interior Point:** An interior point is guaranteed to lie in the interior of the Geometry,
if it is possible to calculate such a point exactly. Otherwise, the point may lie on
the boundary of the geometry.
-* Centroid Point
- * Computes the centroid of a Geometry
+* **Centroid Point**: A centroid point represents the geometric center of a simple geometry. For multi-geometries the
+ center of mass is calculated
***
@@ -61,3 +61,6 @@ A point geometry with EPSG code.
### Example
+<p align="center">
+ <img src="derivedPoint.png" width="500;" class="pe-image-documentation"/>
+</p>
\ No newline at end of file
[streampipes] 01/03: [#1321] first base setup and add resources
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a commit to branch 1321-geo-create-derived-point-of-input-geometry-processor
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 6f3a0df7febbc6026528110c7dc5e54c0cac474b
Author: micklich <mi...@apache.org>
AuthorDate: Mon Feb 20 15:43:23 2023 +0100
[#1321] first base setup and add resources
---
.../interior/CreateInteriorPointProcessor.java | 118 +++++++++++++++++++++
.../documentation.md | 56 ++++++++++
.../icon.png | Bin 0 -> 16877 bytes
.../strings.en | 25 +++++
4 files changed, 199 insertions(+)
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/interior/CreateInteriorPointProcessor.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/interior/CreateInteriorPointProcessor.java
new file mode 100644
index 000000000..8018b84b7
--- /dev/null
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/interior/CreateInteriorPointProcessor.java
@@ -0,0 +1,118 @@
+/*
+ * 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.interior;
+
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import org.apache.streampipes.model.DataProcessorType;
+import org.apache.streampipes.model.graph.DataProcessorDescription;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.model.schema.PropertyScope;
+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.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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CreateInteriorPointProcessor extends StreamPipesDataProcessor {
+ public static final String GEOM_KEY = "geom-key";
+ public static final String EPSG_KEY = "epsg-key";
+ // OUTPUT RUNTIME NAME
+ public static final String INTERIOR_GEOM_KEY = "interior-geom-key";
+ public static final String INTERIOR_EPSG_KEY = "interior-epsg-key";
+ public static final String INTERIOR_GEOM_RUNTIME = "interior-point";
+ public static final String INTERIOR_EPSG_RUNTIME = "epsg-interior-point";
+ private String geometryMapper;
+ private String epsgMapper;
+ private static final Logger LOG = LoggerFactory.getLogger(CreateInteriorPointProcessor.class);
+
+ @Override
+ public DataProcessorDescription declareModel() {
+ return ProcessingElementBuilder.create(
+ "org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior")
+ .category(DataProcessorType.GEO)
+ .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+ .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())
+ // adjust output method
+ .outputStrategy(OutputStrategies.append(
+ EpProperties.stringEp(
+ Labels.withId(INTERIOR_GEOM_KEY),
+ INTERIOR_GEOM_RUNTIME,
+ "http://www.opengis.net/ont/geosparql#Geometry"),
+ EpProperties.integerEp(
+ Labels.withId(INTERIOR_EPSG_KEY),
+ INTERIOR_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);
+
+ }
+ @Override
+ public void onEvent(Event event, SpOutputCollector collector) throws SpRuntimeException {
+ String geom = event.getFieldBySelector(geometryMapper).getAsPrimitive().getAsString();
+ Integer sourceEpsg = event.getFieldBySelector(epsgMapper).getAsPrimitive().getAsInt();
+ Geometry geometry = SpGeometryBuilder.createSPGeom(geom, sourceEpsg);
+ if (geometry instanceof Point) {
+ // TODO remove check after harmonized semantic types and multiple tpes
+ LOG.debug("geom is already a point");
+ } else {
+ Point cendroidPoint = (Point) SpGeometryBuilder.createSPGeom(geometry.getCentroid(), geometry.getSRID());
+ event.addField(INTERIOR_GEOM_RUNTIME, cendroidPoint.toText());
+ event.addField(INTERIOR_EPSG_RUNTIME, cendroidPoint.getSRID());
+ collector.collect(event);
+ }
+ }
+
+ @Override
+ public void onDetach() throws SpRuntimeException {
+
+ }
+}
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/documentation.md b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/documentation.md
new file mode 100755
index 000000000..c6b47978c
--- /dev/null
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/documentation.md
@@ -0,0 +1,56 @@
+<!--
+ ~ 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
+
+Creates an interior point from a geometry other than a Point itself.
+An interior point is guaranteed to lie in the interior of the input geometry, if
+it possible to calculate such a point exactly. Otherwise, the point may
+lie on the boundary of the geometry.
+***
+
+## Required inputs
+
+* JTS Geometry
+* EPSG Code
+***
+
+## Configuration
+
+### Geometry field
+Input Geometry
+
+### EPSG field
+Integer value representing EPSG code
+
+***
+
+## Output
+A point geometry with EPSG code. Location is based on
+
+
+### Example
+
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/icon.png b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/icon.png
new file mode 100644
index 000000000..087d6f1fe
Binary files /dev/null and b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/icon.png differ
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/strings.en b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/strings.en
new file mode 100755
index 000000000..d0b0956d8
--- /dev/null
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/strings.en
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior.title=Geo Create Interior Point
+org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior.description=Creates a Point from other Geometries greater than point
+
+geometry-key.title=JTS Geometry Event
+geometry-key.description=Single Geometry
+
+epsg-key.title=EPSG
+epsg-key.description=EPSG
[streampipes] 02/03: [#1321] add switch between interior and centroid point as output. add resources
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a commit to branch 1321-geo-create-derived-point-of-input-geometry-processor
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 0a9adbf9a83406087a00e26fc3848f6f12cccc50
Author: micklich <mi...@apache.org>
AuthorDate: Thu Feb 23 21:13:36 2023 +0100
[#1321] add switch between interior and centroid point as output. add resources
---
.../streampipes/processors/geo/jvm/GeoJvmInit.java | 4 ++-
.../CreateDerivedPointProcessor.java} | 33 ++++++++++++++-------
.../documentation.md | 17 +++++++----
.../icon.png | Bin
.../strings.en | 7 +++--
5 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
index abaca7715..1a66a3edb 100644
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
@@ -28,6 +28,7 @@ import org.apache.streampipes.messaging.jms.SpJmsProtocolFactory;
import org.apache.streampipes.messaging.kafka.SpKafkaProtocolFactory;
import org.apache.streampipes.messaging.mqtt.SpMqttProtocolFactory;
import org.apache.streampipes.processors.geo.jvm.config.ConfigKeys;
+import org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point.CreateDerivedPointProcessor;
import org.apache.streampipes.processors.geo.jvm.jts.processor.epsg.EpsgProcessor;
import org.apache.streampipes.processors.geo.jvm.jts.processor.latlngtojtspoint.LatLngToJtsPointProcessor;
import org.apache.streampipes.processors.geo.jvm.jts.processor.reprojection.ReprojectionProcessor;
@@ -70,7 +71,8 @@ public class GeoJvmInit extends ExtensionsModelSubmitter {
new LatLngToJtsPointProcessor(),
new TrajectoryFromPointsProcessor(),
new SpeedCalculatorProcessor(),
- new ReprojectionProcessor())
+ new ReprojectionProcessor(),
+ new CreateDerivedPointProcessor())
.registerMessagingFormats(
new JsonDataFormatFactory(),
new CborDataFormatFactory(),
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/interior/CreateInteriorPointProcessor.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java
similarity index 79%
rename from streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/interior/CreateInteriorPointProcessor.java
rename to streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java
index 8018b84b7..0113cc08a 100644
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/interior/CreateInteriorPointProcessor.java
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/derivedgeometry/point/CreateDerivedPointProcessor.java
@@ -16,7 +16,7 @@
*
*/
-package org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior;
+package org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point;
import org.apache.streampipes.commons.exceptions.SpRuntimeException;
import org.apache.streampipes.model.DataProcessorType;
@@ -30,6 +30,7 @@ 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;
@@ -42,22 +43,23 @@ import org.locationtech.jts.geom.Point;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class CreateInteriorPointProcessor extends StreamPipesDataProcessor {
- public static final String GEOM_KEY = "geom-key";
+public class CreateDerivedPointProcessor extends StreamPipesDataProcessor {
+ public static final String GEOM_KEY = "geometry-key";
public static final String EPSG_KEY = "epsg-key";
- // OUTPUT RUNTIME NAME
+ public static final String POINT_OUTPUT_TYPE_KEY = "point-output-type-key";
public static final String INTERIOR_GEOM_KEY = "interior-geom-key";
public static final String INTERIOR_EPSG_KEY = "interior-epsg-key";
public static final String INTERIOR_GEOM_RUNTIME = "interior-point";
public static final String INTERIOR_EPSG_RUNTIME = "epsg-interior-point";
private String geometryMapper;
private String epsgMapper;
- private static final Logger LOG = LoggerFactory.getLogger(CreateInteriorPointProcessor.class);
+ private String outputType;
+ private static final Logger LOG = LoggerFactory.getLogger(CreateDerivedPointProcessor.class);
@Override
public DataProcessorDescription declareModel() {
return ProcessingElementBuilder.create(
- "org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior")
+ "org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point")
.category(DataProcessorType.GEO)
.withAssets(Assets.DOCUMENTATION, Assets.ICON)
.withLocales(Locales.EN)
@@ -72,7 +74,8 @@ public class CreateInteriorPointProcessor extends StreamPipesDataProcessor {
Labels.withId(EPSG_KEY),
PropertyScope.MEASUREMENT_PROPERTY)
.build())
- // adjust output method
+ .requiredSingleValueSelection(Labels.withId(POINT_OUTPUT_TYPE_KEY),
+ Options.from("Centroid Point", "Interior Point"))
.outputStrategy(OutputStrategies.append(
EpProperties.stringEp(
Labels.withId(INTERIOR_GEOM_KEY),
@@ -93,8 +96,10 @@ public class CreateInteriorPointProcessor extends StreamPipesDataProcessor {
this.geometryMapper = parameters.extractor().mappingPropertyValue(GEOM_KEY);
this.epsgMapper = parameters.extractor().mappingPropertyValue(EPSG_KEY);
+ this.outputType = parameters.extractor().selectedSingleValue(POINT_OUTPUT_TYPE_KEY, String.class);
}
+
@Override
public void onEvent(Event event, SpOutputCollector collector) throws SpRuntimeException {
String geom = event.getFieldBySelector(geometryMapper).getAsPrimitive().getAsString();
@@ -104,9 +109,17 @@ public class CreateInteriorPointProcessor extends StreamPipesDataProcessor {
// TODO remove check after harmonized semantic types and multiple tpes
LOG.debug("geom is already a point");
} else {
- Point cendroidPoint = (Point) SpGeometryBuilder.createSPGeom(geometry.getCentroid(), geometry.getSRID());
- event.addField(INTERIOR_GEOM_RUNTIME, cendroidPoint.toText());
- event.addField(INTERIOR_EPSG_RUNTIME, cendroidPoint.getSRID());
+ Point derivedPointOutput = null;
+ switch (this.outputType) {
+ case "Interior Point":
+ derivedPointOutput = (Point) SpGeometryBuilder.createSPGeom(geometry.getInteriorPoint(), geometry.getSRID());
+ break;
+ case "Centroid Point":
+ derivedPointOutput = (Point) SpGeometryBuilder.createSPGeom(geometry.getCentroid(), geometry.getSRID());
+ break;
+ }
+ event.addField(INTERIOR_GEOM_RUNTIME, derivedPointOutput.toText());
+ event.addField(INTERIOR_EPSG_RUNTIME, derivedPointOutput.getSRID());
collector.collect(event);
}
}
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/documentation.md b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md
similarity index 72%
rename from streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/documentation.md
rename to streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md
index c6b47978c..6f9322a2a 100755
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/documentation.md
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/documentation.md
@@ -25,17 +25,15 @@
***
## Description
+Creates a Point of every other Geometry (not included a Point itself).
-Creates an interior point from a geometry other than a Point itself.
-An interior point is guaranteed to lie in the interior of the input geometry, if
-it possible to calculate such a point exactly. Otherwise, the point may
-lie on the boundary of the geometry.
***
## Required inputs
* JTS Geometry
* EPSG Code
+* Point Output Type
***
## Configuration
@@ -46,10 +44,19 @@ Input Geometry
### EPSG field
Integer value representing EPSG code
+### Point Output Type
+Chose between
+* Interior Point
+ * An interior point is guaranteed to lie in the interior of the Geometry,
+ if it is possible to calculate such a point exactly. Otherwise, the point may lie on
+ the boundary of the geometry.
+* Centroid Point
+ * Computes the centroid of a Geometry
+
***
## Output
-A point geometry with EPSG code. Location is based on
+A point geometry with EPSG code.
### Example
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/icon.png b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/icon.png
similarity index 100%
rename from streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/icon.png
rename to streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/icon.png
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/strings.en b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/strings.en
similarity index 82%
rename from streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/strings.en
rename to streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/strings.en
index d0b0956d8..c8b8d84b3 100755
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior/strings.en
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point/strings.en
@@ -15,11 +15,14 @@
# limitations under the License.
#
-org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior.title=Geo Create Interior Point
-org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.interior.description=Creates a Point from other Geometries greater than point
+org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point.title=Geo Derived Point Creation
+org.apache.streampipes.processors.geo.jvm.jts.processor.derivedgeometry.point.description=Creates a Point from other Geometries greater than point
geometry-key.title=JTS Geometry Event
geometry-key.description=Single Geometry
epsg-key.title=EPSG
epsg-key.description=EPSG
+
+point-output-type-key.title=Point Type
+point-output-type-key.description=Choose Output Type