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/16 16:27:45 UTC

[incubator-streampipes-extensions] branch feature/geodesicCalc updated (3d6ecf9 -> 4a5f087)

This is an automated email from the ASF dual-hosted git repository.

micklich pushed a change to branch feature/geodesicCalc
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git.


    from 3d6ecf9  changed round function
     new e6b44d9  makes method public to be used everywhere
     new 670ba67  documentation, icon and strin.en files
     new 4a5f087  adding range check for user input lat lng values

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:
 .../geo/jvm/jts/helper/SpGeometryBuilder.java      |   2 +-
 .../DistanceCalculatorController.java              |  16 ++++++------
 .../StaticDistanceCalculator.java                  |  29 ++++++++++++++++-----
 .../StaticDistanceCalculatorController.java        |   9 +++----
 .../documentation.md                               |  15 ++++++++---
 .../icon.png                                       | Bin 0 -> 5358 bytes
 .../strings.en                                     |  23 +++++++++-------
 .../documentation.md                               |  18 ++++++++++---
 .../icon.png                                       | Bin 0 -> 5611 bytes
 .../strings.en                                     |   8 +++++-
 10 files changed, 82 insertions(+), 38 deletions(-)
 create mode 100644 streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/icon.png
 create mode 100644 streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/icon.png


[incubator-streampipes-extensions] 01/03: makes method public to be used everywhere

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/geodesicCalc
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit e6b44d95b70d968c703cd406ceddd16ccb4d43f4
Author: micklich <fl...@disy.net>
AuthorDate: Sat May 16 18:24:37 2020 +0200

    makes method public to be used everywhere
---
 .../streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 03e38a5..4463087 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
@@ -99,7 +99,7 @@ public class SpGeometryBuilder {
    * @param max          max value to check
    * @return true if value is in min max range
    */
-  private static boolean isInWGSCoordinateRange(double valueToCheck, double min, double max){
+  public static boolean isInWGSCoordinateRange(double valueToCheck, double min, double max){
     return valueToCheck > min && valueToCheck < max;
   }
 


[incubator-streampipes-extensions] 02/03: documentation, icon and strin.en files

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/geodesicCalc
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 670ba67e6fb6b17b8092a7f1c399cdcba892543a
Author: micklich <fl...@disy.net>
AuthorDate: Sat May 16 18:26:55 2020 +0200

    documentation, icon and strin.en files
---
 .../DistanceCalculatorController.java              |  16 +++++++-------
 .../StaticDistanceCalculatorController.java        |   9 ++++----
 .../documentation.md                               |  15 ++++++++++----
 .../icon.png                                       | Bin 0 -> 5358 bytes
 .../strings.en                                     |  23 ++++++++++++---------
 .../documentation.md                               |  18 +++++++++++++---
 .../icon.png                                       | Bin 0 -> 5611 bytes
 .../strings.en                                     |   8 ++++++-
 8 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/distancecalculator/DistanceCalculatorController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/distancecalculator/DistanceCalculatorController.java
index 7bbf3a9..0d7de4c 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/distancecalculator/DistanceCalculatorController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/distancecalculator/DistanceCalculatorController.java
@@ -39,12 +39,12 @@ import java.net.URI;
 
 public class DistanceCalculatorController extends StandaloneEventProcessingDeclarer<DistanceCalculatorParameters> {
 
-  private static final String LAT_1_KEY = "lat1";
-  private static final String LONG_1_KEY = "long1";
-  private static final String LAT_2_KEY = "lat2";
-  private static final String LONG_2_KEY = "long2";
-  private static final String DECIMAL_POSITION_KEY = "decimalPosition";
-  private static final String UNIT_KEY = "unit";
+  private static final String LAT_1_KEY = "lat1-key";
+  private static final String LONG_1_KEY = "long1-key";
+  private static final String LAT_2_KEY = "lat2-key";
+  private static final String LONG_2_KEY = "long2-key";
+  private static final String DECIMAL_POSITION_KEY = "decimalPosition-key";
+  private static final String UNIT_KEY = "unit-key";
 
   private static final String CALCULATED_DISTANCE_KEY = "calculatedDistance";
 
@@ -54,8 +54,8 @@ public class DistanceCalculatorController extends StandaloneEventProcessingDecla
   @Override
   public DataProcessorDescription declareModel() {
     return ProcessingElementBuilder.create("org.apache.streampipes.processors.geo.jvm.processor.distancecalculator")
-        .category(DataProcessorType.FILTER)
-        .withAssets(Assets.DOCUMENTATION)
+        .category(DataProcessorType.GEO)
+        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
         .withLocales(Locales.EN)
         .requiredStream(StreamRequirementsBuilder
             .create()
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java
index e6cca22..814259f 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java
@@ -41,9 +41,8 @@ public class StaticDistanceCalculatorController extends StandaloneEventProcessin
   private static final String LONGITUDE_KEY = "longitude-key";
   private static final String SELECTED_LATITUDE_KEY = "selected-latitude-key";
   private static final String SELECTED_LONGITUDE_KEY = "selected-longitude-key";
-
-  private static final String DECIMAL_POSITION_KEY = "decimalPosition";
-  private static final String UNIT_KEY = "unit";
+  private static final String DECIMAL_POSITION_KEY = "decimalPosition-key";
+  private static final String UNIT_KEY = "unit-key";
 
   protected final static String LENGTH_RUNTIME = "geodesicStaticDistance";
   protected final static String UNIT_RUNTIME = "geodesicStaticDistanceUnit";
@@ -52,8 +51,8 @@ public class StaticDistanceCalculatorController extends StandaloneEventProcessin
   public DataProcessorDescription declareModel() {
     return ProcessingElementBuilder.create("org.apache.streampipes.processors.geo.jvm.processor" +
         ".staticdistancecalculator")
-        .category(DataProcessorType.FILTER)
-        .withAssets(Assets.DOCUMENTATION)
+        .category(DataProcessorType.GEO)
+        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
         .withLocales(Locales.EN)
         .requiredStream(StreamRequirementsBuilder
             .create()
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/documentation.md b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/documentation.md
index f221b91..6f9e510 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/documentation.md
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/documentation.md
@@ -18,7 +18,7 @@
 
 ## Distance Calculator
 
-<p align="center"> 
+<p align="center">
     <img src="icon.png" width="150px;" class="pe-image-documentation"/>
 </p>
 
@@ -26,22 +26,29 @@
 
 ## Description
 
-Calculates the distance between two latitude/longitude pairs in a single event.
+Calculates the geodesic distance between two latitude/longitude pairs in a single event.
 
 ***
 
 ## Required input
 
+* Latitude and Longitude values of Position 1
+* Latitude and Longitude values of Position 2
 
 ***
 
 ## Configuration
 
-Describe the configuration parameters here
+Calculates the geodesic distance between position 1 and position 2. The User can choose the unit of the output value and the number of decimal positions.
 
 ### 1st parameter
 
+Number of the decimal position between 0 and 10.
 
 ### 2nd parameter
 
-## Output
\ No newline at end of file
+Unit of the output result. Possible Units are Meter, KM, Feet or Mile.
+
+***
+
+## Output
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/icon.png b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/icon.png
new file mode 100644
index 0000000..866ae01
Binary files /dev/null and b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/icon.png differ
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/strings.en
index a6507f8..c9676ac 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/strings.en
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.distancecalculator/strings.en
@@ -1,17 +1,20 @@
 org.apache.streampipes.processors.geo.jvm.processor.distancecalculator.title=Distance Calculator
 org.apache.streampipes.processors.geo.jvm.processor.distancecalculator.description=Calculates the distance between two geo points
 
-lat1.title=First Latitude
-lat1.description=
+lat1-key.title=First Latitude
+lat1-key.description= Latitude of Position 1
 
-long1.title=First Longitude
-long1.description=
+long1-key.title=First Longitude
+long1-key.description= Longitude of Position 1
 
-lat2.title=Second Latitude
-lat2.description=
+lat2-key.title=Second Latitude
+lat2-key.description=Latitude of Position 2
 
-long2.title=Second Longitude
-long2.description=
+long2-key.title=Second Longitude
+long2-key.description=Longitude of Position 2
 
-calculatedDistance.title=Distance Field
-startingCell.description=
\ No newline at end of file
+decimalPosition-key.title Decimal Position of Result
+decimalPosition-key.description =  Number of decimal position
+
+unit-key.title=Units
+unit-key.description=Available Units of the  result
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/documentation.md b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/documentation.md
index eb70028..3b99ab3 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/documentation.md
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/documentation.md
@@ -22,7 +22,7 @@
 
 ## Description
 
-Calculates the distance (in km) between a fixed location (e.g., a place) and a latitude/longitude pair of an input
+Calculates the distance between a fixed location (e.g., a place) and a latitude/longitude pair of an input
  event.
 
 ***
@@ -35,11 +35,23 @@ Requires a data stream that provides latitude and longitude values.
 
 ## Configuration
 
-Describe the configuration parameters here
+Calculates the geodesic distance between a position and a usr input position. The User can choose the unit of the output value and the number of decimal positions.
+
 
 ### 1st parameter
 
+Number of the decimal position between 0 and 10.
 
 ### 2nd parameter
 
-## Output
\ No newline at end of file
+Unit of the output result. Possible Units are Meter, KM, Feet or Mile.
+
+### 3rd parameter
+Static latitude value in decimal degrees (needs to be in range -90 and 90)
+
+### 4th parameter
+Static longitude field in decimal degrees (needs to be in range 180 and 90)
+
+***
+
+## Output
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/icon.png b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/icon.png
new file mode 100644
index 0000000..2168342
Binary files /dev/null and b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/icon.png differ
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/strings.en
index 4238a5b..2bf42ee 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/strings.en
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator/strings.en
@@ -11,4 +11,10 @@ selected-latitude-key.title=Latitude
 selected-latitude-key.description=The latitude value of the fixed location
 
 selected-longitude-key.title=Longitude
-selected-longitude-key.description=The longitude value of the fixed location
\ No newline at end of file
+selected-longitude-key.description=The longitude value of the fixed location
+
+decimalPosition-key.title Decimal Position
+decimalPosition-key.description =  Number of decimal position
+
+unit-key.title=Units
+unit-key.description=Available Units of the result


[incubator-streampipes-extensions] 03/03: adding range check for user input lat lng values

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/geodesicCalc
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 4a5f08797cb0f65d62b620105fba0e7d54ea5434
Author: micklich <fl...@disy.net>
AuthorDate: Sat May 16 18:27:24 2020 +0200

    adding range check for user input lat lng values
---
 .../StaticDistanceCalculator.java                  | 29 +++++++++++++++++-----
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java
index 0b5eca8..d0e95a4 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java
@@ -17,14 +17,19 @@
 package org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator;
 
 import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import org.apache.streampipes.logging.api.Logger;
 import org.apache.streampipes.model.runtime.Event;
 import org.apache.streampipes.processors.geo.jvm.processor.util.SpLengthCalculator;
 import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
 import org.apache.streampipes.wrapper.routing.SpOutputCollector;
 import org.apache.streampipes.wrapper.runtime.EventProcessor;
 
+import org.apache.streampipes.processors.geo.jvm.jts.helper.SpGeometryBuilder;
+
 public class StaticDistanceCalculator implements EventProcessor<StaticDistanceCalculatorParameters> {
 
+  private static Logger LOG;
+
   private String latitudeFieldName;
   private String longitudeFieldName;
 
@@ -37,6 +42,8 @@ public class StaticDistanceCalculator implements EventProcessor<StaticDistanceCa
 
   @Override
   public void onInvocation(StaticDistanceCalculatorParameters parameters, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException {
+    LOG = parameters.getGraph().getLogger(StaticDistanceCalculatorParameters.class);
+
     this.latitudeFieldName = parameters.getLatitudeFieldName();
     this.longitudeFieldName = parameters.getLongitudeFieldName();
 
@@ -53,16 +60,26 @@ public class StaticDistanceCalculator implements EventProcessor<StaticDistanceCa
     Double latitude = event.getFieldBySelector(latitudeFieldName).getAsPrimitive().getAsDouble();
     Double longitude = event.getFieldBySelector(longitudeFieldName).getAsPrimitive().getAsDouble();
 
-    staticLength.calcGeodesicDistance(latitude, longitude, selectedLocationLatitude, selectedLocationLongitude);
+    if ((SpGeometryBuilder.isInWGSCoordinateRange(latitude, -90, 90))
+        && (SpGeometryBuilder.isInWGSCoordinateRange(longitude, -180, 180))) {
+
+      staticLength.calcGeodesicDistance(latitude, longitude, selectedLocationLatitude, selectedLocationLongitude);
+
+      if (unit != 1) {
+        staticLength.convertUnit(unit);
+      }
+
+      event.addField(StaticDistanceCalculatorController.LENGTH_RUNTIME, staticLength.getLengthValueRoundet());
+      event.addField(StaticDistanceCalculatorController.UNIT_RUNTIME, staticLength.getLengthUnit());
 
-    if (unit != 1) {
-      staticLength.convertUnit(unit);
+      collector.collect(event);
+    } else {
+      //todo how to handle error visible to the user
+      LOG.error("User Longitude and Latitude value are out of Range. "
+          + latitude  + ": allowed -90 and 90)" + longitude  + ": allowed -180 and 180)" );
     }
 
-    event.addField(StaticDistanceCalculatorController.LENGTH_RUNTIME, staticLength.getLengthValueRoundet());
-    event.addField(StaticDistanceCalculatorController.UNIT_RUNTIME, staticLength.getLengthUnit());
 
-    collector.collect(event);
   }
 
   @Override