diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 447:5606ba4139e0

WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation. flys-artifacts/trunk@1939 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 18 May 2011 08:04:54 +0000
parents 5d65fe4c08d5
children 9814d4808410
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Tue May 17 16:31:07 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed May 18 08:04:54 2011 +0000
@@ -252,12 +252,15 @@
             throw new NullPointerException("No Kms selected.");
         }
 
-        double[] qs = getQs();
+        double[] qs   = getQs();
+        double[] ws   = null;
+        boolean  qSel = true;
+
         if (qs == null) {
             logger.debug("Determine Q values based on a set of W values.");
-
-            double[] ws = getWs();
-            qs = getQsForWs(ws);
+            qSel = false;
+            ws   = getWs();
+            qs   = getQsForWs(ws);
         }
 
         WstValueTable wst = WstValueTableFactory.getTable(river);
@@ -265,9 +268,28 @@
             throw new NullPointerException("No Wst found for selected river.");
         }
 
+        WQKms[] results = computeWaterlevelData(kms, qs, wst);
+
         // TODO Introduce a caching mechanism here!
 
-        return computeWaterlevelData(kms, qs, wst);
+        setWaterlevelNames(results, qSel ? qs : ws, qSel ? "Q" : "W");
+
+        return results;
+    }
+
+
+    /**
+     * Sets the name for waterlevels where each WQKms in <i>r</i> represents a
+     * column.
+     *
+     * @param r The waterlevel columns.
+     * @param v The input values of the computations.
+     * @param wq The WQ mode - can be one of "W" or "Q".
+     */
+    public static void setWaterlevelNames(WQKms[] r, double[] v, String wq) {
+        for (int i = 0; i < v.length; i++) {
+            r[i].setName(wq + "=" + Double.toString(v[i]));
+        }
     }
 
 

http://dive4elements.wald.intevation.org