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 2020/05/12 08:16:14 UTC
[incubator-streampipes-extensions] 02/03: changed from label.from
to withID
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a commit to branch feature/latLngGeo
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git
commit d7b5bbe5ce887feca8a827a61e60275a3e5cea59
Author: micklich <fl...@disy.net>
AuthorDate: Mon May 11 23:52:20 2020 +0200
changed from label.from to withID
---
.../jvm/jts/processor/latLngToGeo/LatLngToGeo.java | 18 +++--
.../latLngToGeo/LatLngToGeoController.java | 79 +++++++++------------
.../latLngToGeo/LatLngToGeoParameter.java | 10 +--
.../geo/jvm/jts/processor/setEPSG/SetEPSG.java | 9 +--
.../jts/processor/setEPSG/SetEpsgController.java | 52 +++++++-------
.../jts/processor/setEPSG/SetEpsgParameter.java | 10 +--
.../strings.en | 7 +-
.../icon.png | Bin 4831 -> 8710 bytes
.../strings.en | 9 ++-
9 files changed, 93 insertions(+), 101 deletions(-)
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeo.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeo.java
index 25bbf6a..13adaeb 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeo.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeo.java
@@ -30,23 +30,29 @@ import org.apache.streampipes.model.runtime.Event;
public class LatLngToGeo implements EventProcessor<LatLngToGeoParameter> {
private static Logger LOG;
- private LatLngToGeoParameter params;
+ private String latitude;
+ private String longitude;
+ private String epsg_code;
@Override
public void onInvocation(LatLngToGeoParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
LOG = params.getGraph().getLogger(LatLngToGeoParameter.class);
- this.params = params;
+ this.latitude = params.getLat();
+ this.longitude= params.getLng();
+ this.epsg_code = params.getEpsg();
+
}
@Override
public void onEvent(Event in, SpOutputCollector out) {
- Double lat = in.getFieldBySelector(params.getLat()).getAsPrimitive().getAsDouble();
- Double lng = in.getFieldBySelector(params.getLng()).getAsPrimitive().getAsDouble();
- Integer epsg_value = in.getFieldBySelector(params.getEpsg_value()).getAsPrimitive().getAsInt();
- Point geom = SpGeometryBuilder.createSPGeom(lng, lat, epsg_value);
+ Double lat = in.getFieldBySelector(latitude).getAsPrimitive().getAsDouble();
+ Double lng = in.getFieldBySelector(longitude).getAsPrimitive().getAsDouble();
+ Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
+
+ Point geom = SpGeometryBuilder.createSPGeom(lng, lat, epsg);
if (!geom.isEmpty()){
in.addField(LatLngToGeoController.WKT, geom.toString());
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoController.java
index 78b5791..aa1d027 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoController.java
@@ -22,65 +22,54 @@ import org.apache.streampipes.model.DataProcessorType;
import org.apache.streampipes.model.graph.DataProcessorDescription;
import org.apache.streampipes.model.graph.DataProcessorInvocation;
import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.sdk.builder.PrimitivePropertyBuilder;
import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
import org.apache.streampipes.sdk.helpers.*;
import org.apache.streampipes.sdk.utils.Assets;
+import org.apache.streampipes.sdk.utils.Datatypes;
import org.apache.streampipes.vocabulary.Geo;
-import org.apache.streampipes.vocabulary.SO;
import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
public class LatLngToGeoController extends StandaloneEventProcessingDeclarer<LatLngToGeoParameter> {
- public final static String LAT_FIELD = "lat_field";
- public final static String LNG_FIELD = "lng_field";
- public final static String EPSG = "EPSG";
- public final static String WKT = "geom_wkt";
- public final static String EPA_NAME = "Create Point from Latitude and Longitude";
+ public final static String LAT_KEY = "latitude-key";
+ public final static String LNG_KEY = "longitude-key";
+ public final static String EPSG_KEY = "epsg-key";
+
+ public final static String WKT = "geom-wkt";
+ public final static String EPA_NAME = "Create Point from Latitude and Longitude";
@Override
public DataProcessorDescription declareModel() {
return ProcessingElementBuilder
- .create("org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo",
- EPA_NAME,
- "Creates a point geometry from Latitude and Longitude values")
- .category(DataProcessorType.GEO)
- .withAssets(Assets.DOCUMENTATION, Assets.ICON)
- .requiredStream(
- StreamRequirementsBuilder
- .create()
- .requiredPropertyWithUnaryMapping(
- EpRequirements.domainPropertyReq(Geo.lat),
- Labels.from(LAT_FIELD,
- "Latitude field",
- "Latitude value"),
- PropertyScope.NONE
- )
- .requiredPropertyWithUnaryMapping(
- EpRequirements.domainPropertyReq(Geo.lng),
- Labels.from(LNG_FIELD,
- "Longitude field",
- "Longitude value"),
- PropertyScope.NONE
- )
- .requiredPropertyWithUnaryMapping(
- EpRequirements.numberReq(),
- Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
- PropertyScope.NONE
- )
- .build()
+ .create("org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo")
+ .category(DataProcessorType.GEO)
+ .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+ .withLocales(Locales.EN)
+ .requiredStream(
+ StreamRequirementsBuilder
+ .create()
+ .requiredPropertyWithUnaryMapping(EpRequirements.domainPropertyReq(Geo.lat),
+ Labels.withId(LAT_KEY), PropertyScope.MEASUREMENT_PROPERTY)
+ .requiredPropertyWithUnaryMapping(
+ EpRequirements.domainPropertyReq(Geo.lng),
+ Labels.withId(LNG_KEY), PropertyScope.MEASUREMENT_PROPERTY)
+ .requiredPropertyWithUnaryMapping(
+ EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
+ Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY)
+ .build()
)
- .outputStrategy(OutputStrategies.append(EpProperties.stringEp(
- Labels.from(
- "point_wkt",
- "wkt",
- "wkt point from long lat values"),
- WKT,
- SO.Text))
+ .outputStrategy(
+ OutputStrategies.append(
+ PrimitivePropertyBuilder
+ .create(Datatypes.String, WKT)
+ .domainProperty("http://www.opengis.net/ont/geosparql#Geometry")
+ .build())
)
.supportedFormats(SupportedFormats.jsonFormat())
@@ -93,11 +82,11 @@ public class LatLngToGeoController extends StandaloneEventProcessingDeclarer<La
public ConfiguredEventProcessor<LatLngToGeoParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
- String lat = extractor.mappingPropertyValue(LAT_FIELD);
- String lng = extractor.mappingPropertyValue(LNG_FIELD);
- String epsg_value = extractor.mappingPropertyValue(EPSG);
+ String lat = extractor.mappingPropertyValue(LAT_KEY);
+ String lng = extractor.mappingPropertyValue(LNG_KEY);
+ String epsg = extractor.mappingPropertyValue(EPSG_KEY);
- LatLngToGeoParameter params = new LatLngToGeoParameter(graph, epsg_value, lat, lng);
+ LatLngToGeoParameter params = new LatLngToGeoParameter(graph, epsg, lat, lng);
return new ConfiguredEventProcessor<>(params, LatLngToGeo::new);
}
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoParameter.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoParameter.java
index 631860f..9ae8795 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoParameter.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/latLngToGeo/LatLngToGeoParameter.java
@@ -23,20 +23,20 @@ import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams
public class LatLngToGeoParameter extends EventProcessorBindingParams {
- private String epsg_value;
+ private String epsg;
private String lat;
private String lng;
- public LatLngToGeoParameter(DataProcessorInvocation graph, String epsg_code, String lat, String lng) {
+ public LatLngToGeoParameter(DataProcessorInvocation graph, String epsg, String lat, String lng) {
super(graph);
- this.epsg_value = epsg_code;
+ this.epsg = epsg;
this.lat = lat;
this.lng = lng;
}
- public String getEpsg_value() {
- return epsg_value;
+ public String getEpsg() {
+ return epsg;
}
public String getLat() {
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEPSG.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEPSG.java
index 71dc243..18b4d91 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEPSG.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEPSG.java
@@ -29,7 +29,7 @@ public class SetEPSG implements EventProcessor<SetEpsgParameter> {
public static Logger LOG;
public SetEpsgParameter params;
- public Integer epsg_value;
+ public Integer epsg;
@@ -37,13 +37,14 @@ public class SetEPSG implements EventProcessor<SetEpsgParameter> {
public void onInvocation(SetEpsgParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
LOG = params.getGraph().getLogger(SetEPSG.class);
- this.params = params;
- this.epsg_value = params.getEpsg_value();
+ this.epsg = params.getEpsg();
}
@Override
public void onEvent(Event in, SpOutputCollector out) {
- in.addField(SetEpsgController.EPSG, epsg_value);
+ //in.addField("epsg-key", epsg);
+ in.addField("epsg", epsg);
+
out.collect(in);
}
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgController.java
index 9426320..aef69a2 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgController.java
@@ -21,10 +21,13 @@ package org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG;
import org.apache.streampipes.model.DataProcessorType;
import org.apache.streampipes.model.graph.DataProcessorDescription;
import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.sdk.builder.PrimitivePropertyBuilder;
import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
import org.apache.streampipes.sdk.helpers.*;
+import org.apache.streampipes.sdk.utils.Datatypes;
import org.apache.streampipes.vocabulary.SO;
import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
@@ -32,44 +35,37 @@ import org.apache.streampipes.sdk.utils.Assets;
public class SetEpsgController extends StandaloneEventProcessingDeclarer<SetEpsgParameter> {
- public final static String EPSG = "EPSG";
public final static String EPA_NAME = "EPSG Enricher";
+ public final static String EPSG_KEY = "epsg-key";
+
@Override
public DataProcessorDescription declareModel() {
return ProcessingElementBuilder
- .create("org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG",
- EPA_NAME,
- "Adds an EPSG Code to the event")
- .category(DataProcessorType.GEO)
- .withAssets(Assets.DOCUMENTATION, Assets.ICON)
- .requiredStream
- (StreamRequirementsBuilder
- .create()
- .build())
- .requiredIntegerParameter(
- Labels.from(
- EPSG,
- "Sets EPSG Code",
- "Sets an EPSG Code. Default ist WGS84/WGS84 with number 4326"),
- 4326)
- .outputStrategy(
- OutputStrategies.append(
- EpProperties.numberEp(
- Labels.from(
- "EPSG Code",
- "EPSG Code",
- "EPSG Code for SRID"),
- EPSG, SO.Number)))
- .supportedFormats(SupportedFormats.jsonFormat())
- .supportedProtocols(SupportedProtocols.kafka())
- .build();
+ .create("org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG")
+ .category(DataProcessorType.GEO)
+ .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+ .withLocales(Locales.EN)
+ .requiredStream(StreamRequirementsBuilder
+ .create()
+ .build())
+ .requiredIntegerParameter(Labels.withId(EPSG_KEY), 4326)
+
+ .outputStrategy(
+ OutputStrategies.append(PrimitivePropertyBuilder
+ .create(Datatypes.Integer, "epsg")
+ .domainProperty("http://data.ign.fr/def/ignf#CartesianCS")
+ .build())
+ )
+ .supportedFormats(SupportedFormats.jsonFormat())
+ .supportedProtocols(SupportedProtocols.kafka())
+ .build();
}
@Override
public ConfiguredEventProcessor<SetEpsgParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
- Integer epsg_value = extractor.singleValueParameter(EPSG, Integer.class);
+ Integer epsg_value = extractor.singleValueParameter(EPSG_KEY, Integer.class);
SetEpsgParameter params = new SetEpsgParameter(graph, epsg_value);
return new ConfiguredEventProcessor<>(params, SetEPSG::new);
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgParameter.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgParameter.java
index 9601f22..1745af3 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgParameter.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/setEPSG/SetEpsgParameter.java
@@ -24,14 +24,14 @@ import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams
public class SetEpsgParameter extends EventProcessorBindingParams {
- private Integer epsg_value;
+ private Integer epsg;
- public SetEpsgParameter(DataProcessorInvocation graph, Integer epsg_code) {
+ public SetEpsgParameter(DataProcessorInvocation graph, Integer epsg) {
super(graph);
- this.epsg_value = epsg_code;
+ this.epsg = epsg;
}
- public Integer getEpsg_value() {
- return epsg_value;
+ public Integer getEpsg() {
+ return epsg;
}
}
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo/strings.en
index 433141b..5e0e27e 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo/strings.en
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo/strings.en
@@ -1,5 +1,6 @@
org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo.title=Creates JTS Point
-org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo.description=Creats a JTS Point from Latitude and Longitude values
+org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo.description=Creates a JTS Point from Latitude and Longitude values
-place.title=JTS Point
-place.description=JTS Point Geometry
+latitude-key=Latitude value
+longitude-key=Longitude value
+epsg-key= EPSG Code
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/icon.png b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/icon.png
index 3bc916a..d2a81e7 100644
Binary files a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/icon.png and b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/icon.png differ
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/strings.en
index 3da6df1..599f7a7 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/strings.en
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG/strings.en
@@ -1,6 +1,5 @@
-org.apache.streampipes.processor.geo.jvm.staticgeocoding.title=Static Google Maps Geocoder
-org.apache.streampipes.processor.geo.jvm.staticgeocoding.description=Geocodes a fixed placename to lat/lng coordinates and
-appends these coordinates to every input event.
+org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG.title=EPSG Code
+org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG.description=Adds a corresponding EPSG Code to the Geo-Event
-place.title=Place
-place.description=The place name that should be converted to a lat/lng combination
\ No newline at end of file
+epsg-key.title=EPSG Code field
+epsg-key.description=EPSG Code