annotate artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java @ 9299:4a6cc7c6716a

uinfo.inundation_duration veg'zone select
author gernotbelger
date Wed, 25 Jul 2018 14:42:44 +0200
parents e4606eae8ea5
children
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;
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
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22
7615
edb323a4c286 (issue1620) join column names with two empty spaces
Andre Heinecke <aheinecke@intevation.de>
parents: 7604
diff changeset
23 import org.apache.commons.lang.StringUtils;
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
24 import org.apache.log4j.Logger;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3284
diff changeset
25 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
26
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 /**
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 * 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
29 *
7656
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
30 * 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
31 *
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
32 * HEADER
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
33 * Q-LINE
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
34 * W-LINES
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
35 * Q-LINE
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
36 * W-LINES
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
37 * ...
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
38 *
ad5238e3e736 Cosmetics of WstWriter. Actually, a decent class now.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7654
diff changeset
39 * 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
40 *
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 * @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
42 */
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 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
44
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7663
diff changeset
45 /** The log used in this class. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7663
diff changeset
46 private static Logger log = Logger.getLogger(WstWriter.class);
446
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 default unit that is written into the header of the WST. */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
49 public static final String DEFAULT_UNIT = "Wasserstand [NN + m]";
446
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 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
52 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
53
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
54 /** 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
55 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
56
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
57 /** 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
58 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
59
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
60 /** 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
61 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
62
3147
d9fb3a178be4 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 749
diff changeset
63 /** 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
64 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
65
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
66 /**
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
67 * Workaround for one use of wrongly imported files: ignore the Qs at
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
68 * all.
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
69 */
7658
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
70 protected boolean ignoreQs;
446
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 /**
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3147
diff changeset
73 * 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
74 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
75 * @param columns
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
76 * 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
77 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
78 public WstWriter(final int columns) {
7658
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
79 this(columns, false);
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
80 }
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
81
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
82 /**
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
83 * This constructor creates a new WstWriter with a number of Q columns.
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
84 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
85 * @param columns
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
86 * The number of columns of the resulting WST.
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
87 * @param workaroundIgnoreQs
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
88 * do not write QLines to shadow broken data.
7658
4fb5e89e7bd3 issue1020: WstWriter: Add flag to ignore Qs alltogether.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7656
diff changeset
89 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
90 public WstWriter(final int columns, final boolean workaroundIgnoreQs) {
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
91 this.cols = columns;
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
92 this.columnNames = new ArrayList<>(this.cols);
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
93 this.lines = new HashMap<>();
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
94 this.qs = new double[this.cols];
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
95 this.locale = Locale.US;
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
96 this.ignoreQs = workaroundIgnoreQs;
446
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 * 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
101 * inserted using add(double[]) before.
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
102 *
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
103 * @param out
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
104 * 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
105 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
106 public void write(final OutputStream out) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7663
diff changeset
107 log.info("WstWriter.write");
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
109 final PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
111 this.qs = new double[this.cols];
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
112
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 writeHeader(writer);
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
115 final Collection<WstLine> collection = new TreeMap(this.lines).values();
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
117 for (final WstLine line : collection) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 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
119 }
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 writer.flush();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 writer.close();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 }
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 * 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
127 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
128 * @param wqkms
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
129 * 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
130 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
131 public void add(final double[] wqkms) {
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
132 final Double km = wqkms[2];
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
134 WstLine line = this.lines.get(km);
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 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
137 line = new WstLine(km.doubleValue());
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
138 this.lines.put(km, line);
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 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
142 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
144 public void addCorrected(final double[] wqckms) {
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
145 final Double km = wqckms[2];
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
147 WstLine line = this.lines.get(km);
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
148
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
149 if (line == null) {
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
150 line = new WstLine(km.doubleValue());
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
151 this.lines.put(km, line);
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
152 }
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
153
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
154 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
155 }
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
156
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 /**
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
158 * 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
159 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
160 * @param name
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
161 * The name of the new column.
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
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 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
164 if (name != null) {
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
165 this.cols++;
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
166
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
167 int i = 0;
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
168 final String basename = name;
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
169 while (this.columnNames.contains(name)) {
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
170 name = basename + "_" + i++;
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
171 }
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
172
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
173 this.columnNames.add(name);
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 }
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
175 }
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
176
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
177 /**
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 * 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
179 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
180 * @param writer
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
181 * The PrintWriter that creates the output.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
183 protected void writeHeader(final PrintWriter writer) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7663
diff changeset
184 log.debug("WstWriter.writeHeader");
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
186 writer.println(this.cols);
7654
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 writer.print("*!column-bez-text ");
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
189
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
190 final List<String> quotedNames = new ArrayList<>(this.columnNames.size());
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
191
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
192 for (String name : this.columnNames) {
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
193 if (name.contains(" ")) {
7663
7c89a545617a Use correct quotes for long names
Andre Heinecke <aheinecke@intevation.de>
parents: 7658
diff changeset
194 name = '"' + name + '"';
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
195 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
196 quotedNames.add(name);
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 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
199 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
200
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
201 for (final String columnName : this.columnNames) {
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
202 if (columnName.length() > 9) {
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
203 writer.printf(this.locale, "%9s", columnName.substring(columnName.length() - 9));
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
204 } else {
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
205 writer.printf(this.locale, "%9s", columnName);
7654
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
206 // 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
207 // how to do this another way.
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
208 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
209 writer.print(" ");
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
210 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
211 }
197bd0958cba (issue1620) Fix WstWriter Column Header format.
Andre Heinecke <aheinecke@intevation.de>
parents: 7615
diff changeset
212 }
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
213
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
214 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
215
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 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
217 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
218 writer.println();
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
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 * 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
223 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
224 * @param writer
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
225 * The PrintWriter that is used to create the output.
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
226 * @param line
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
227 * The WstLine that should be written to the output.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
229 protected void writeWLine(final PrintWriter writer, final WstLine line) {
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
230 final double km = line.getKm();
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
231 final double[] qs = line.getQs();
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
232 final int num = line.getSize();
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
234 if (!this.ignoreQs && dischargesChanged(qs)) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 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
236 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
238 writer.printf(this.locale, "%8.3f", km);
446
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 for (int i = 0; i < num; i++) {
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
241 writer.printf(this.locale, "%9.2f", line.getW(i));
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 writer.println();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 }
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 * 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
249 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
250 * @param qs
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
251 * the Q values for the next range.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
253 protected void writeQLine(final PrintWriter writer, final double[] qs) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 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
255
749
72bcbc308501 The WST export contains the corrected W values now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 447
diff changeset
256 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
257 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
258
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
259 writer.printf(this.locale, "%9.2f", qs[i]);
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 writer.println();
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
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 * 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
267 * current one.
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 *
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
269 * @param newQs
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
270 * The Q values of the next line.
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 *
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 * @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
273 */
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
274 protected boolean dischargesChanged(final double[] newQs) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 // XXX maybe there is a way to do this faster
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
276 for (int i = 0; i < this.cols && i < this.qs.length && i < newQs.length; i++) {
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
277 if (Math.abs(newQs[i] - this.qs[i]) >= 0.001) {
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 return true;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 return false;
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 }
7604
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
284
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
285 /**
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
286 * 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
287 * 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
288 */
7604
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
289 public Map<Double, WstLine> getLines() {
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents: 8202
diff changeset
290 return this.lines;
7604
05549a84ee83 (issue1620) Add export of official lines in WST as specified
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
291 }
446
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 }
c0bec245f608 Implemented writer that creates WSTs and enabled the WaterlevelExporter to create those.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org