Skip to content

Commit

Permalink
[#1321] extend documentary. Add log output to log field
Browse files Browse the repository at this point in the history
  • Loading branch information
flomickl committed Feb 24, 2023
1 parent 0a9adbf commit 6a00daf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,14 +58,15 @@ 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
public DataProcessorDescription declareModel() {
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()
Expand Down Expand Up @@ -97,17 +102,19 @@ public void onInvocation(ProcessorParams parameters, SpOutputCollector spOutputC
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) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

***

Expand All @@ -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

***

Expand All @@ -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>

0 comments on commit 6a00daf

Please sign in to comment.