diff flys-artifacts/src/main/java/de/intevation/flys/exports/WstWriter.java @ 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 5606ba4139e0
children d9fb3a178be4
line wrap: on
line diff
--- 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