annotate artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java @ 7656:ad5238e3e736

Cosmetics of WstWriter. Actually, a decent class now.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 05 Dec 2013 22:04:15 +0100
parents 197bd0958cba
children 4fb5e89e7bd3
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3284
diff changeset
9 package org.dive4elements.river.exports;
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.io.BufferedWriter;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.io.OutputStream;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import java.io.OutputStreamWriter;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import java.io.PrintWriter;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
16 import java.util.ArrayList;
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import java.util.Collection;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import java.util.HashMap;
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
19 import java.util.List;
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import java.util.Locale;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import java.util.Map;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import java.util.TreeMap;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import org.apache.log4j.Logger;
7615
edb323a4c286 (issue1620) join column names with two empty spaces
Andre Heinecke <aheinecke@intevation.de>
parents: 7604
diff changeset
25 import org.apache.commons.lang.StringUtils;
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3284
diff changeset
27 import org.dive4elements.river.artifacts.model.WstLine;
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 * A writer that creates WSTs.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 *
7656
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
33 * Wst files follow this basic structure:
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
34 *
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
35 * HEADER
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
36 * Q-LINE
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
37 * W-LINES
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
38 * Q-LINE
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
39 * W-LINES
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
40 * ...
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
41 *
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
42 * where each *LINE consists of X columns that are specified in the header.
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
43 *
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public class WstWriter {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
48 /** The logger used in this class. */
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 private static Logger logger = Logger.getLogger(WstWriter.class);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
51 /** The default unit that is written into the header of the WST. */
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 public static final String DEFAULT_UNIT = "Wassserstand [NN + m]";
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
54 /** The lines that need to be included for the export. */
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 protected Map<Double, WstLine> lines;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
57 /** The column names. */
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
58 protected List<String> columnNames;
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
59
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
60 /** The locale used to format the values. */
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 protected Locale locale;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
63 /** The number of discharge columns. */
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 protected int cols;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
66 /** The last Q values. */
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 protected double[] qs;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 /**
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3147
diff changeset
71 * This constructor creates a new WstWriter with a number of Q columns.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 *
7656
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
73 * @param columns The number of columns of the resulting WST.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 */
7656
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
75 public WstWriter(int columns) {
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
76 this.cols = columns;
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
77 this.columnNames = new ArrayList<String>(cols);
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
78 this.lines = new HashMap<Double, WstLine>();
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
79 this.qs = new double[cols];
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
80 this.locale = Locale.US;
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 * This method is used to create the WST from the data that has been
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 * inserted using add(double[]) before.
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3147
diff changeset
87 * @param out Where to write to.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 public void write(OutputStream out) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 logger.info("WstWriter.write");
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 PrintWriter writer = new PrintWriter(
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 new BufferedWriter(
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 new OutputStreamWriter(out)));
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
96 this.qs = new double[cols];
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
97
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 writeHeader(writer);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 Collection<WstLine> collection = new TreeMap(lines).values();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 for (WstLine line: collection) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 writeWLine(writer, line);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 writer.flush();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 writer.close();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 * This method is used to add a new line to the WST.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 *
7656
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
114 * @param wqkms A 3dim double array with [W, Q, KM].
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 public void add(double[] wqkms) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 Double km = wqkms[2];
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 WstLine line = lines.get(km);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 if (line == null) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 line = new WstLine(km.doubleValue());
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 lines.put(km, line);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 line.add(wqkms[0], wqkms[1]);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
130 public void addCorrected(double[] wqckms) {
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
131 Double km = wqckms[2];
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
132
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
133 WstLine line = lines.get(km);
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
134
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
135 if (line == null) {
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
136 line = new WstLine(km.doubleValue());
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
137 lines.put(km, line);
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
138 }
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
139
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
140 line.add(wqckms[3], wqckms[1]);
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
141 }
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
142
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
143
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 /**
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
145 * Adds a further column name.
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
146 *
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
147 * @param name The name of the new column.
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
148 */
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
149 public void addColumn(String name) {
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
150 if (name != null) {
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
151 cols++;
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
152
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
153 int i = 0;
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
154 String basename = name;
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
155 while (columnNames.contains(name)) {
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
156 name = basename + "_" + i++;
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
157 }
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
158
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
159 columnNames.add(name);
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
160 }
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
161 }
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
162
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
163
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
164 /**
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 * This method writes the header of the WST.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 *
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 * @param writer The PrintWriter that creates the output.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 protected void writeHeader(PrintWriter writer) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 logger.debug("WstWriter.writeHeader");
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 writer.println(cols);
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
173
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
174 writer.print("*!column-bez-text ");
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
175
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
176 List<String> quotedNames = new ArrayList<String>(columnNames.size());
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
177
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
178 for (String name: columnNames) {
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
179 if (name.contains(" ")) {
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
180 name = "'" + name + "'";
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
181 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
182 quotedNames.add(name);
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
183 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
184 writer.println(StringUtils.join(quotedNames, " "));
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
185 writer.print(" ");
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
187 for (String columnName: columnNames) {
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
188 if (columnName.length() > 9) {
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
189 writer.printf(locale, "%9s",
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
190 columnName.substring(columnName.length() - 9));
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
191 } else {
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
192 writer.printf(locale, "%9s", columnName);
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
193 // This is weird but i was to lazy to lookup
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
194 // how to do this another way.
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
195 for (int i = 9 - columnName.length(); i > 0; i--) {
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
196 writer.print(" ");
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
197 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
198 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
199 }
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
200
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 446
diff changeset
201 writer.println();
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 writer.write("* KM ");
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 writer.write(DEFAULT_UNIT);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 writer.println();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 * This method writes a line with W values and a certain kilometer.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 *
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 * @param writer The PrintWriter that is used to create the output.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 * @param line The WstLine that should be written to the output.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 protected void writeWLine(PrintWriter writer, WstLine line) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 double km = line.getKm();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 double[] qs = line.getQs();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 int num = line.getSize();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 if (dischargesChanged(qs)) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 writeQLine(writer, qs);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 writer.printf(locale, "%8.3f", km);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 for (int i = 0; i < num; i++) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 writer.printf(locale, "%9.2f", line.getW(i));
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 writer.println();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 * Writes a discharge line (Q values) into a WST.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 *
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 * @param qs the Q values for the next range.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 protected void writeQLine(PrintWriter writer, double[] qs) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 writer.write("*\u001f ");
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
242 for (int i = 0; i < qs.length; i++) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 this.qs[i] = qs[i];
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 writer.printf(locale, "%9.2f", qs[i]);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 writer.println();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 * This method determines if a Q has changed from the last line to the
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 * current one.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 *
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 * @param newQs The Q values of the next line.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 *
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 * @return true, if a Q value have changed, otherwise false.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 protected boolean dischargesChanged(double[] newQs) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 // XXX maybe there is a way to do this faster
7604
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
262 for (int i = 0; i < cols && i < qs.length && i < newQs.length; i++) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 if (Math.abs(newQs[i] - qs[i]) >= 0.001) {
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 return true;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 return false;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 }
7604
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
270
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
271 /**
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
272 * Get the lines that have alreay been added to this writer
7656
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
273 * lines are a map with km as the key and a wstline as value.
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
274 */
7604
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
275 public Map<Double, WstLine> getLines() {
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
276 return lines;
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
277 }
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org