diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 450:c8bb38115290

Enabled the discharge longitudinal section to be exported as WST. flys-artifacts/trunk@1944 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 18 May 2011 10:59:38 +0000
parents 9814d4808410
children 73bc64c4a7b0
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed May 18 09:11:10 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed May 18 10:59:38 2011 +0000
@@ -495,7 +495,11 @@
         double[][] dist = getSplittedDistance();
         int        num  = dist != null ? dist.length : 0;
 
-        WQKms[][] wqkms = new WQKms[num][];
+        double[][] allQs = new double[num][];
+        double[][] allWs = new double[num][];
+        WQKms[][]  wqkms = new WQKms[num][];
+
+        boolean qSel = true;
 
         for (int i = 0; i < num; i++) {
             double[] kms = getKms(dist[i]);
@@ -505,11 +509,14 @@
             }
 
             double[] qs = getQs(dist[i]);
+            allQs[i]    = qs;
+
             if (qs == null) {
                 logger.debug("Determine Q values based on a set of W values.");
+                qSel = false;
 
-                double[] ws = getWs(dist[i]);
-                qs = getQsForWs(ws);
+                allWs[i] = getWs(dist[i]);
+                qs       = getQsForWs(allWs[i]);
             }
 
             wqkms[i] = computeWaterlevelData(kms, qs, wst);
@@ -521,6 +528,12 @@
 
         for (int i = 0; i < numMerged; i++) {
             computed[i] = computeDischargeLongitudinalSectionData(merged[i]);
+
+            setDischargeLongitudinalSectionNames(
+                computed[i],
+                qSel ? allQs : allWs,
+                i,
+                qSel ? "Q" : "W");
         }
 
         // TODO Introduce a caching mechanism here!
@@ -530,6 +543,46 @@
 
 
     /**
+     * Sets the name for discharge longitudinal section curves where each WQKms
+     * in <i>r</i> represents a column.
+     *
+     * @param wqkms A longitudinal section curve.
+     * @param allValues The input values of the computations.
+     * @param col The requested column in the table of Ws or Qs.
+     * @param wq The WQ mode - can be one of "W" or "Q".
+     */
+    public static void setDischargeLongitudinalSectionNames(
+        WQKms      wqkms,
+        double[][] allValues,
+        int        col,
+        String     wq)
+    {
+        logger.debug("WINFOArtifact.setDischargeLongitudinalSectionNames");
+
+        StringBuilder sb = new StringBuilder(" (");
+        boolean    first = true;
+
+        int rows = allValues.length;
+
+        for (int i = 0; i < rows; i++) {
+            double[] values = allValues[i];
+
+            if (!first) {
+                sb.append("; ");
+            }
+
+            sb.append(Double.toString(values[col]));
+
+            first = false;
+        }
+
+        sb.append(")");
+
+        wqkms.setName(wq + " Benutzerdefiniert" + sb.toString());
+    }
+
+
+    /**
      * Computes the data used for a discharge longitudinal section based on a
      * given WQKms object. If there are backjumps while computing the data, a
      * WQCKms object is returned, otherwise the incoming wqkms object.

http://dive4elements.wald.intevation.org