Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java @ 7654:197bd0958cba
(issue1620) Fix WstWriter Column Header format.
- Size is always 9 for a name, fill with spaces if not.
- column-bez-text is the longform if a name contains spaces it is
quoted.
This should enable more exotic waterlevel names which are needed
for issue1020
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 05 Dec 2013 19:29:52 +0100 |
parents | edb323a4c286 |
children | ad5238e3e736 |
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 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * @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
|
34 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 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
|
36 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
37 /** 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
|
38 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
|
39 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
40 /** 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
|
41 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
|
42 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
43 /** 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
|
44 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
|
45 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
46 /** 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
|
47 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
|
48 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
49 /** 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
|
50 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
|
51 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
52 /** 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
|
53 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
|
54 |
3147
d9fb3a178be4
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
749
diff
changeset
|
55 /** 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
|
56 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
|
57 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 /** |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3147
diff
changeset
|
61 * 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
|
62 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 * @param cols The number of columns of the resulting WST. |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 public WstWriter(int cols) { |
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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 /** |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 * 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
|
75 * inserted using add(double[]) before. |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3147
diff
changeset
|
76 * @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
|
77 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 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
|
79 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
|
80 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 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
|
82 new BufferedWriter( |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 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
|
84 |
749
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
85 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
|
86 |
446
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 writeHeader(writer); |
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 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
|
90 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 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
|
92 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
|
93 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 writer.flush(); |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 writer.close(); |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
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 /** |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 * 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
|
102 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 * @param wqkms A 3dim double array with [W,Q, KM]. |
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 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
|
106 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
|
107 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 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
|
109 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 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
|
116 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
749
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
119 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
|
120 Double km = wqckms[2]; |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
121 |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
122 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
|
123 |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
124 if (line == null) { |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
125 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
|
126 lines.put(km, line); |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
127 } |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
128 |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
129 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
|
130 } |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
131 |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
132 |
446
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 /** |
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
|
134 * 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
|
135 * |
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
|
136 * @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
|
137 */ |
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
|
138 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
|
139 if (name != null) { |
749
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
140 cols++; |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
141 |
7654
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
142 int i = 0; |
749
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
143 String basename = name; |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
144 while (columnNames.contains(name)) { |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
145 name = basename + "_" + i++; |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
146 } |
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
147 |
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
|
148 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
|
149 } |
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 } |
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
|
151 |
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
|
152 |
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
|
153 /** |
446
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 * 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
|
155 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 * @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
|
157 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 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
|
159 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
|
160 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 writer.println(cols); |
7654
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
162 |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
163 writer.print("*!column-bez-text "); |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
164 |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
165 List<String> quotedNames = new ArrayList<String>(columnNames.size()); |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
166 |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
167 for (String name: columnNames) { |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
168 if (name.contains(" ")) { |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
169 name = "'" + name + "'"; |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
170 } |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
171 quotedNames.add(name); |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
172 } |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
173 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
|
174 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
|
175 |
7654
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
176 for (String columnName: columnNames) { |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
177 if (columnName.length() > 9) { |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
178 writer.printf(locale, "%9s", |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
179 columnName.substring(columnName.length() - 9)); |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
180 } else { |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
181 writer.printf(locale, "%9s", columnName); |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
182 // 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
|
183 // how to do this another way. |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
184 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
|
185 writer.print(" "); |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
186 } |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
187 } |
197bd0958cba
(issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents:
7615
diff
changeset
|
188 } |
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
|
189 |
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
|
190 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
|
191 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 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
|
193 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
|
194 writer.println(); |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 /** |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 * 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
|
200 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 * @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
|
202 * @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
|
203 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 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
|
210 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
|
211 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 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
|
214 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 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
|
216 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
|
217 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 writer.println(); |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 } |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
221 |
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 * 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
|
225 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 * @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
|
227 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 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
|
229 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
|
230 |
749
72bcbc308501
The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
231 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
|
232 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
|
233 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 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
|
235 } |
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 writer.println(); |
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 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
240 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
241 /** |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 * 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
|
243 * current one. |
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 * @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
|
246 * |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
247 * @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
|
248 */ |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
249 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
|
250 // 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
|
251 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
|
252 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
|
253 return true; |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
254 } |
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 |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
257 return false; |
c0bec245f608
Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 } |
7604
05549a84ee83
(issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
259 |
05549a84ee83
(issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
260 /** |
05549a84ee83
(issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
261 * Get the lines that have alreay been added to this writer |
05549a84ee83
(issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
262 * lines are a map with km as the key and a wstline as value */ |
05549a84ee83
(issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
263 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
|
264 return lines; |
05549a84ee83
(issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
265 } |
446
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |