[PATCH 22 of 45] (issue1754) Add km filtering for winfo anf fixanal results in difference calculations

Wald Commits scm-commit at wald.intevation.org
Tue Mar 10 17:05:50 CET 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1424097077 -3600
# Node ID fa57a2cb1dfa5e8eebe5525565c245ff60ba326f
# Parent  11646c8dfa61111221bc28a0c2aa9a80bb2083cf
(issue1754) Add km filtering for winfo anf fixanal results in difference calculations

diff -r 11646c8dfa61 -r fa57a2cb1dfa artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Mon Feb 16 15:30:22 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Mon Feb 16 15:31:17 2015 +0100
@@ -124,6 +124,7 @@
             return null;
         }
 
+        WKms retval = null;
         if (d4eArtifact instanceof StaticWKmsArtifact) {
             StaticWKmsArtifact staticWKms = (StaticWKmsArtifact) d4eArtifact;
             log.debug("WDifferencesState obtain data from StaticWKms");
@@ -132,7 +133,7 @@
                 log.error("No WKms from Static artifact for this range.");
                 return new WQKms();
             }
-            return wkms;
+            return wkms; /* No need for additional km filtering */
         } else if (d4eArtifact instanceof WINFOArtifact) {
             log.debug("Get WKms from WINFOArtifact");
             WINFOArtifact flys = (WINFOArtifact) d4eArtifact;
@@ -144,9 +145,9 @@
             }
             else if (wkms.length < idx+1) {
                 log.warn("Not enough waterlevels in artifact.");
-                return new WQKms();
+                retval = new WQKms();
             }
-            return wkms[idx];
+            retval = wkms[idx];
         } else if (d4eArtifact instanceof MINFOArtifact) {
             log.warn("Get WKms from MINFOArtifact not implemented!");
 //            CalculationResult r = (CalculationResult)
@@ -156,11 +157,20 @@
             CalculationResult r = (CalculationResult)
                 d4eArtifact.compute(context, ComputeType.ADVANCE, false);
             FixRealizingResult frR = (FixRealizingResult) r.getData();
-            return frR.getWQKms()[idx];
+            retval = frR.getWQKms()[idx];
         }
 
-        log.error("Do not know how to handle (getWKms) minuend/subtrahend");
-        return null;
+
+        if (retval == null) {
+            log.error("Do not know how to handle (getWKms) minuend/subtrahend");
+        } else if (!Double.isNaN(from) && !Double.isNaN(to)) {
+            /* Filter out only the relevant data points for calulation results.*/
+            log.debug("Before filter: " + retval.size());
+            retval = retval.filteredKms(from, to);
+            log.debug("After filter: " + retval.size());
+        }
+
+        return retval;
     }
 
 


More information about the Dive4Elements-commits mailing list