changeset 8552:fa57a2cb1dfa

(issue1754) Add km filtering for winfo anf fixanal results in difference calculations
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 16 Feb 2015 15:31:17 +0100
parents 11646c8dfa61
children 17c476e90c07
files artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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;
     }
 
 

http://dive4elements.wald.intevation.org