changeset 738:5abdb2fa8eb1

Fix for flys/issue147 flys-artifacts/trunk@2234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 26 Jun 2011 14:46:48 +0000
parents 6b38b8488401
children 08a3c3651e36
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java
diffstat 4 files changed, 33 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sun Jun 26 13:07:44 2011 +0000
+++ b/flys-artifacts/ChangeLog	Sun Jun 26 14:46:48 2011 +0000
@@ -1,3 +1,17 @@
+2011-06-26  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	Fix for flys/issue147
+
+	* src/main/java/de/intevation/flys/artifacts/model/Calculation1.java:
+	  Removed the 'kmUp' flag. It was an left over from former
+	  WSP calculations (w/o ref km) leading to wrong results now.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java:
+	  Don't pass the kmUp flag to the calculation.
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
+	  Added debug output to see the value of 'wq_free'.
+
 2011-06-26  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	Fix for flys/issue86
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Sun Jun 26 13:07:44 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Sun Jun 26 14:46:48 2011 +0000
@@ -772,7 +772,9 @@
         StateData mode  = getData("wq_free");
         String    value = mode != null ? (String) mode.getValue() : null;
 
-        if (mode == null) {
+        logger.debug("isFreeQ: " + value);
+
+        if (value == null) {
             return false;
         }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Sun Jun 26 13:07:44 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Sun Jun 26 14:46:48 2011 +0000
@@ -344,14 +344,19 @@
             return error(new WQKms[0], "No Wst found for selected river.");
         }
 
-        double refKm = Double.NaN;
 
-        if (!isFreeQ()) {
-            double [] range = getDistance();
-            if (range == null) {
-                return error(new WQKms[0], "No range found");
-            }
+        double [] range = getDistance();
+        if (range == null) {
+            return error(new WQKms[0], "No range found");
+        }
 
+        double refKm;
+
+        if (isFreeQ()) {
+            refKm = range[0];
+            logger.debug("'free' calculation (km " + refKm + ")");
+        }
+        else {
             Gauge gauge = river.determineGaugeByPosition(range[0]);
             if (gauge == null) {
                 return error(
@@ -364,8 +369,7 @@
                 "reference gauge: " + gauge.getName() + " (km " + refKm + ")");
         }
 
-        return computeWaterlevelData(
-            kms, qs, ws, wst, refKm, river.getKmUp());
+        return computeWaterlevelData(kms, qs, ws, wst, refKm);
     }
 
     /**
@@ -383,12 +387,11 @@
         double []     qs,
         double []     ws,
         WstValueTable wst,
-        double        refKm,
-        boolean       up
+        double        refKm
     ) {
         logger.info("WINFOArtifact.computeWaterlevelData");
 
-        Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm, up);
+        Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm);
 
         return calc1.calculate(wst);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java	Sun Jun 26 13:07:44 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java	Sun Jun 26 14:46:48 2011 +0000
@@ -12,7 +12,6 @@
     protected double [] kms;
     protected double [] qs;
     protected double [] ws;
-    protected boolean   up;
     protected double    refKm;
 
     public Calculation1() {
@@ -22,24 +21,18 @@
         double [] kms, 
         double [] qs, 
         double [] ws,
-        double    refKm,
-        boolean   up
+        double    refKm
     ) {
         this.kms   = kms;
         this.qs    = qs;
         this.ws    = ws;
         this.refKm = refKm;
-        this.up    = up;
     }
 
     public CalculationResult calculate(WstValueTable wst) {
 
         ArrayList<WQKms> results = new ArrayList<WQKms>();
 
-        double ref = Double.isNaN(refKm)
-            ? kms[up ? 0 : kms.length-1]
-            : refKm;
-
         String    prefix;
         double [] origData;
 
@@ -54,7 +47,7 @@
             double [] ows = new double[kms.length];
 
             boolean success =
-                wst.interpolate(qs[i], ref, kms, ows, oqs, this) != null;
+                wst.interpolate(qs[i], refKm, kms, ows, oqs, this) != null;
 
             int newNumProblems = numProblems();
 

http://dive4elements.wald.intevation.org