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:37:55 UTC
[incubator-streampipes-extensions] 05/05: adding feature to dev and
code formating
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git
commit b6bfcb9f3485a1d1bd28d86eba3afa063a6a3021
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 10:15:58 2020 +0200
adding feature to dev and code formating
---
.../geo/jvm/jts/helper/SpGeometryBuilder.java | 17 ++--
.../jvm/jts/processor/latLngToGeo/LatLngToGeo.java | 58 +++++++-------
.../latLngToGeo/LatLngToGeoController.java | 90 +++++++++++-----------
.../latLngToGeo/LatLngToGeoParameter.java | 36 ++++-----
.../geo/jvm/jts/processor/setEPSG/SetEPSG.java | 35 ++++-----
.../jts/processor/setEPSG/SetEpsgController.java | 58 +++++++-------
.../jts/processor/setEPSG/SetEpsgParameter.java | 16 ++--
7 files changed, 155 insertions(+), 155 deletions(-)
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
index c72635a..274796c 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
@@ -28,10 +28,11 @@ public class SpGeometryBuilder {
final static double LATITIDE_MAX = 90;
- /**Creates a JTS point geometry from Longitude and Latitude values
+ /**
+ * Creates a JTS point geometry from Longitude and Latitude values
*
- * @param lng Longitude value in the range -180 <Longitude > 180
- * @param lat Latitude value in the range -90 <LATITUDE > 90
+ * @param lng Longitude value in the range -180 <Longitude > 180
+ * @param lat Latitude value in the range -90 <LATITUDE > 90
* @param epsg EPSG Code for projection onfo
* @return a JTS Point Geometry Object with lat lng values. An empty point geometry is created if Latitude or Longitude values are out of range
* or has null values.
@@ -61,13 +62,12 @@ public class SpGeometryBuilder {
}
/**
- *
* @param checkedvalue Any Value
- * @param min Min value to check
- * @param max max value to check
+ * @param min Min value to check
+ * @param max max value to check
* @return boolean value true or false
*/
- private static boolean isInWGSCoordinateRange(double checkedvalue, double min, double max){
+ private static boolean isInWGSCoordinateRange(double checkedvalue, double min, double max) {
return checkedvalue > min && checkedvalue < max;
}
@@ -76,6 +76,7 @@ public class SpGeometryBuilder {
* Creates a JTS PrecisionModel with a specific precision.
* WGS84/WGS84 will be created with 7 decimal positions.
* Any other epsg code will create a precision with Ffloating type. See JTS PrecisionModel for more information
+ *
* @param epsg EPSG alue
* @return a JTS PrecisionModel
*/
@@ -84,7 +85,7 @@ public class SpGeometryBuilder {
if (epsg == 4326) {
// use scale precision with 7 decimal positions like default OSM
- precisionModel = new PrecisionModel(1000000);
+ precisionModel = new PrecisionModel(1000000);
} else {
// use default constructor
precisionModel = new PrecisionModel();
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 13adaeb..a746583 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
@@ -29,44 +29,44 @@ import org.apache.streampipes.model.runtime.Event;
public class LatLngToGeo implements EventProcessor<LatLngToGeoParameter> {
- private static Logger LOG;
- private String latitude;
- private String longitude;
- private String epsg_code;
+ private static Logger LOG;
+ private String latitude;
+ private String longitude;
+ private String epsg_code;
- @Override
- public void onInvocation(LatLngToGeoParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
+ @Override
+ public void onInvocation(LatLngToGeoParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
- LOG = params.getGraph().getLogger(LatLngToGeoParameter.class);
- this.latitude = params.getLat();
- this.longitude= params.getLng();
- this.epsg_code = params.getEpsg();
+ LOG = params.getGraph().getLogger(LatLngToGeoParameter.class);
+ this.latitude = params.getLat();
+ this.longitude = params.getLng();
+ this.epsg_code = params.getEpsg();
- }
+ }
+
+ @Override
+ public void onEvent(Event in, SpOutputCollector out) {
- @Override
- public void onEvent(Event in, SpOutputCollector out) {
+ Double lat = in.getFieldBySelector(latitude).getAsPrimitive().getAsDouble();
+ Double lng = in.getFieldBySelector(longitude).getAsPrimitive().getAsDouble();
+ Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
- 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);
- Point geom = SpGeometryBuilder.createSPGeom(lng, lat, epsg);
+ if (!geom.isEmpty()) {
+ in.addField(LatLngToGeoController.WKT, geom.toString());
+ out.collect(in);
+ } else {
+ LOG.warn("An empty point geometry in " + LatLngToGeoController.EPA_NAME + " is created due" +
+ "invalid input field. Latitude: " + lat + "Longitude: " + lng);
+ LOG.error("Event is filtered out due invalid geometry");
- if (!geom.isEmpty()){
- in.addField(LatLngToGeoController.WKT, geom.toString());
- out.collect(in);
- } else {
- LOG.warn("An empty point geometry in " + LatLngToGeoController.EPA_NAME + " is created due" +
- "invalid input field. Latitude: " + lat + "Longitude: " + lng);
- LOG.error("Event is filtered out due invalid geometry");
-
- }
}
+ }
- @Override
- public void onDetach() {
+ @Override
+ public void onDetach() {
- }
+ }
}
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 aa1d027..d9a82c9 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
@@ -33,61 +33,61 @@ import org.apache.streampipes.vocabulary.Geo;
import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
-public class LatLngToGeoController extends StandaloneEventProcessingDeclarer<LatLngToGeoParameter> {
+public class LatLngToGeoController extends StandaloneEventProcessingDeclarer<LatLngToGeoParameter> {
- 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 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";
+ 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")
- .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(
- PrimitivePropertyBuilder
- .create(Datatypes.String, WKT)
- .domainProperty("http://www.opengis.net/ont/geosparql#Geometry")
- .build())
- )
+ @Override
+ public DataProcessorDescription declareModel() {
+ return ProcessingElementBuilder
+ .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(
+ PrimitivePropertyBuilder
+ .create(Datatypes.String, WKT)
+ .domainProperty("http://www.opengis.net/ont/geosparql#Geometry")
+ .build())
+ )
- .supportedFormats(SupportedFormats.jsonFormat())
- .supportedProtocols(SupportedProtocols.kafka())
- .build();
- }
+ .supportedFormats(SupportedFormats.jsonFormat())
+ .supportedProtocols(SupportedProtocols.kafka())
+ .build();
+ }
- @Override
- public ConfiguredEventProcessor<LatLngToGeoParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
+ @Override
+ public ConfiguredEventProcessor<LatLngToGeoParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
- String lat = extractor.mappingPropertyValue(LAT_KEY);
- String lng = extractor.mappingPropertyValue(LNG_KEY);
- String epsg = extractor.mappingPropertyValue(EPSG_KEY);
+ String lat = extractor.mappingPropertyValue(LAT_KEY);
+ String lng = extractor.mappingPropertyValue(LNG_KEY);
+ String epsg = extractor.mappingPropertyValue(EPSG_KEY);
- LatLngToGeoParameter params = new LatLngToGeoParameter(graph, epsg, lat, lng);
+ LatLngToGeoParameter params = new LatLngToGeoParameter(graph, epsg, lat, lng);
- return new ConfiguredEventProcessor<>(params, LatLngToGeo::new);
- }
+ 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 9ae8795..b8a2a06 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,27 +23,27 @@ import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams
public class LatLngToGeoParameter extends EventProcessorBindingParams {
- private String epsg;
- private String lat;
- private String lng;
+ private String epsg;
+ private String lat;
+ private String lng;
- public LatLngToGeoParameter(DataProcessorInvocation graph, String epsg, String lat, String lng) {
- super(graph);
- this.epsg = epsg;
- this.lat = lat;
- this.lng = lng;
- }
+ public LatLngToGeoParameter(DataProcessorInvocation graph, String epsg, String lat, String lng) {
+ super(graph);
+ this.epsg = epsg;
+ this.lat = lat;
+ this.lng = lng;
+ }
- public String getEpsg() {
- return epsg;
- }
+ public String getEpsg() {
+ return epsg;
+ }
- public String getLat() {
- return lat;
- }
+ public String getLat() {
+ return lat;
+ }
- public String getLng() {
- return lng;
- }
+ public String getLng() {
+ return lng;
+ }
}
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 18b4d91..f4a0851 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
@@ -27,29 +27,28 @@ import org.apache.streampipes.model.runtime.Event;
public class SetEPSG implements EventProcessor<SetEpsgParameter> {
- public static Logger LOG;
- public SetEpsgParameter params;
- public Integer epsg;
+ public static Logger LOG;
+ public SetEpsgParameter params;
+ public Integer epsg;
+ @Override
+ public void onInvocation(SetEpsgParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
- @Override
- public void onInvocation(SetEpsgParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
+ LOG = params.getGraph().getLogger(SetEPSG.class);
+ this.epsg = params.getEpsg();
+ }
- LOG = params.getGraph().getLogger(SetEPSG.class);
- this.epsg = params.getEpsg();
- }
+ @Override
+ public void onEvent(Event in, SpOutputCollector out) {
+ //in.addField("epsg-key", epsg);
+ in.addField("epsg", epsg);
- @Override
- public void onEvent(Event in, SpOutputCollector out) {
- //in.addField("epsg-key", epsg);
- in.addField("epsg", epsg);
+ out.collect(in);
+ }
- out.collect(in);
- }
+ @Override
+ public void onDetach() {
- @Override
- public void onDetach() {
-
- }
+ }
}
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 aef69a2..db76c74 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
@@ -35,39 +35,39 @@ import org.apache.streampipes.sdk.utils.Assets;
public class SetEpsgController extends StandaloneEventProcessingDeclarer<SetEpsgParameter> {
- public final static String EPA_NAME = "EPSG Enricher";
+ public final static String EPA_NAME = "EPSG Enricher";
- public final static String EPSG_KEY = "epsg-key";
+ public final static String EPSG_KEY = "epsg-key";
- @Override
- public DataProcessorDescription declareModel() {
- return ProcessingElementBuilder
- .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)
+ @Override
+ public DataProcessorDescription declareModel() {
+ return ProcessingElementBuilder
+ .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();
- }
+ .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) {
+ @Override
+ public ConfiguredEventProcessor<SetEpsgParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
- Integer epsg_value = extractor.singleValueParameter(EPSG_KEY, Integer.class);
- SetEpsgParameter params = new SetEpsgParameter(graph, epsg_value);
+ Integer epsg_value = extractor.singleValueParameter(EPSG_KEY, Integer.class);
+ SetEpsgParameter params = new SetEpsgParameter(graph, epsg_value);
- return new ConfiguredEventProcessor<>(params, SetEPSG::new);
- }
+ 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 1745af3..a08141e 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;
+ private Integer epsg;
- public SetEpsgParameter(DataProcessorInvocation graph, Integer epsg) {
- super(graph);
- this.epsg = epsg;
- }
+ public SetEpsgParameter(DataProcessorInvocation graph, Integer epsg) {
+ super(graph);
+ this.epsg = epsg;
+ }
- public Integer getEpsg() {
- return epsg;
- }
+ public Integer getEpsg() {
+ return epsg;
+ }
}