changeset 8667:0c241f03ebcd

(issue1755) Only add facets / results when they do not consist exlcusively of NaN values.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 08 Apr 2015 19:09:38 +0200
parents 1a4ad0d4231a
children fc5fcec91b73
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityResultValue.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java
diffstat 3 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java	Wed Apr 08 18:15:55 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java	Wed Apr 08 19:09:38 2015 +0200
@@ -92,7 +92,7 @@
     protected void addValuesToResult(BedQualityResult result,
                                      BedQualityResultValue[] values) {
         for (BedQualityResultValue value: values) {
-            if (value.isEmpty()) {
+            if (value.isEmpty() || value.isNaN()) {
                 if (value.isDiameterResult()) {
                     log.debug("Adding diameter problem");
                     addProblem("bedquality.missing.diameter." +
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityResultValue.java	Wed Apr 08 18:15:55 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityResultValue.java	Wed Apr 08 19:09:38 2015 +0200
@@ -77,6 +77,18 @@
         return data == null || data.length < 2 || data[0].length == 0;
     }
 
+    public boolean isNaN() {
+        if (isEmpty()) {
+            return true;
+        }
+        for (int i = 0; i < data[0].length; i++) {
+            if (!Double.isNaN(data[1][i])) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public boolean isInterpolateable() {
         return isInterpolatableData;
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Wed Apr 08 18:15:55 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Wed Apr 08 19:09:38 2015 +0200
@@ -131,7 +131,17 @@
             if (d != null) {
                 double [][] data = (double[][]) d;
                 if (data.length > 0 && data[0].length > 0) {
-                    newFacets.add(candidate);
+                    boolean onlyNaN = true;
+                    for (int i = 0; i < data.length; i++) {
+                        if (!Double.isNaN(data[1][i])) {
+                            onlyNaN = false;
+                            break;
+                        }
+                        if (!onlyNaN) {
+                            newFacets.add(candidate);
+                        }
+                        // else adding a problem would be nice
+                    }
                 }
             }
         }

http://dive4elements.wald.intevation.org