changeset 6981:2fed93751ecb

issue1457: Handle symbolic discharge of -1 as 'no discharge'.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 10 Sep 2013 11:49:01 +0200 (2013-09-10)
parents 07e31234d294
children 5149e6e5c2eb
files artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Mon Sep 09 16:05:31 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Tue Sep 10 11:49:01 2013 +0200
@@ -305,24 +305,23 @@
 
 
     /**
-     * Return true if all values in data[0] are zero or very close to it.
+     * Return true if all values in data[0] are smaller than zero
+     * (in imported data they are set to -1 symbolically).
      * Return false if data is null or empty
      */
-    private boolean zeroQ(double[][] data) {
+    private boolean hasNoDischarge(double[][] data) {
         if (data == null || data.length == 0) {
             return false;
         }
 
-        boolean allZero = true;
-
         double[] qs = data[0];
         for (double q: qs) {
-            if (Math.abs(q) >= 0.01d) {
-                allZero = false;
+            if (q > 0d) {
+                return false;
             }
         }
 
-        return allZero;
+        return true;
     }
 
 
@@ -342,8 +341,8 @@
 
         double translate = getCurrentGaugeDatum();
 
-        // If no Q values (all zero) foud, add annotations
-        if (zeroQ(data)) {
+        // If no Q values (i.e. all -1) found, add annotations.
+        if (hasNoDischarge(data)) {
             List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
 
             for (double y: data[1]) {

http://dive4elements.wald.intevation.org