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 17:00:16 UTC

[incubator-streampipes-extensions] branch feature/geodesicCalc updated: throw exceptions instead of log if lat lng out of range

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


The following commit(s) were added to refs/heads/feature/geodesicCalc by this push:
     new 4c4b3bc  throw exceptions instead of log if lat lng out of range
4c4b3bc is described below

commit 4c4b3bceb370444499ad67ca98f95a57a73a3d4e
Author: micklich <fl...@disy.net>
AuthorDate: Sat May 16 18:59:56 2020 +0200

    throw exceptions instead of log if lat lng out of range
---
 .../StaticDistanceCalculator.java                        | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 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 d0e95a4..6b680a4 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
@@ -28,8 +28,6 @@ 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;
 
@@ -42,7 +40,6 @@ 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();
@@ -73,13 +70,16 @@ public class StaticDistanceCalculator implements EventProcessor<StaticDistanceCa
       event.addField(StaticDistanceCalculatorController.UNIT_RUNTIME, staticLength.getLengthUnit());
 
       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)" );
+      if ((SpGeometryBuilder.isInWGSCoordinateRange(latitude, -90, 90))) {
+        throw new SpRuntimeException("Input of Latitude value is out of range. Value: "
+            + latitude + " but allowed between -90 and 90)");
+      } else {
+        throw new SpRuntimeException("Input of Longitude value is out of range. Value "
+            + longitude + " but allowed between -180 and 180)");
+      }
     }
-
-
   }
 
   @Override