changeset 749:72bcbc308501

The WST export contains the corrected W values now. flys-artifacts/trunk@2257 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 27 Jun 2011 16:07:24 +0000
parents 30be4b71c36c
children b24be063f8d2 20928eef3ccd
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/WstWriter.java
diffstat 3 files changed, 48 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jun 27 14:06:16 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jun 27 16:07:24 2011 +0000
@@ -1,3 +1,9 @@
+2011-06-27  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/WaterlevelExporter.java,
+	  src/main/java/de/intevation/flys/exports/WstWriter.java:
+	  Append the corrected W column (if existing) to the WST export.
+
 2011-06-27  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WQ.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Mon Jun 27 14:06:16 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Mon Jun 27 16:07:24 2011 +0000
@@ -15,6 +15,7 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.WQCKms;
 import de.intevation.flys.artifacts.model.WQKms;
 
 import de.intevation.flys.utils.Formatter;
@@ -155,7 +156,7 @@
     protected void writeWSTData(WstWriter writer) {
         logger.debug("WaterlevelExporter.writeWSTData");
 
-        double[] result = new double[3];
+        double[] result = new double[4];
 
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
@@ -168,6 +169,16 @@
 
                     writer.add(result);
                 }
+
+                if (wqkms instanceof WQCKms) {
+                    addWSTColumn(writer, wqkms);
+
+                    for (int c = 0; c < size; c++) {
+                        result = wqkms.get(c, result);
+
+                        writer.addCorrected(result);
+                    }
+                }
             }
         }
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WstWriter.java	Mon Jun 27 14:06:16 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WstWriter.java	Mon Jun 27 16:07:24 2011 +0000
@@ -62,8 +62,6 @@
         this.lines       = new HashMap<Double, WstLine>();
         this.qs          = new double[cols];
         this.locale      = Locale.US;
-        this.cols        = cols;
-
     }
 
 
@@ -78,6 +76,8 @@
             new BufferedWriter(
                 new OutputStreamWriter(out)));
 
+        this.qs = new double[cols];
+
         writeHeader(writer);
 
         Collection<WstLine> collection = new TreeMap(lines).values();
@@ -110,6 +110,20 @@
     }
 
 
+    public void addCorrected(double[] wqckms) {
+        Double km = wqckms[2];
+
+        WstLine line = lines.get(km);
+
+        if (line == null) {
+            line = new WstLine(km.doubleValue());
+            lines.put(km, line);
+        }
+
+        line.add(wqckms[3], wqckms[1]);
+    }
+
+
     /**
      * Adds a further column name.
      *
@@ -117,6 +131,19 @@
      */
     public void addColumn(String name) {
         if (name != null) {
+            cols++;
+
+            String basename = name;
+
+            int i = 0;
+            while (columnNames.contains(name)) {
+                name = basename + "_" + i++;
+
+                if (name.length() > 9) {
+                    name = name.substring(name.length() - 9);
+                }
+            }
+
             columnNames.add(name);
         }
     }
@@ -178,7 +205,7 @@
     protected void writeQLine(PrintWriter writer, double[] qs) {
         writer.write("*\u001f      ");
 
-        for (int i = 0; i < cols; i++) {
+        for (int i = 0; i < qs.length; i++) {
             this.qs[i] = qs[i];
 
             writer.printf(locale, "%9.2f", qs[i]);

http://dive4elements.wald.intevation.org