[PATCH] (issue1755) Only add facets / results when they do not consist exlcusively of NaN values

Wald Commits scm-commit at wald.intevation.org
Thu Apr 9 09:48:00 CEST 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1428512978 -7200
# Node ID 0c241f03ebcdd8f36d885d2825ac5044acb5a068
# Parent  1a4ad0d4231a15cc943048e20dc405aedd3aa914
(issue1755) Only add facets / results when they do not consist exlcusively of NaN values.

diff -r 1a4ad0d4231a -r 0c241f03ebcd artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java
--- 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." +
diff -r 1a4ad0d4231a -r 0c241f03ebcd artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityResultValue.java
--- 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;
     }
diff -r 1a4ad0d4231a -r 0c241f03ebcd artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java
--- 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
+                    }
                 }
             }
         }


More information about the Dive4Elements-commits mailing list