Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java @ 3576:6442f317a0c7
i18n and renderering of qsectors in w/q diag.
flys-artifacts/trunk@5191 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 10 Aug 2012 12:30:39 +0000 |
parents | 0c8a6145098b |
children | 67bbcee26e21 |
rev | line source |
---|---|
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import java.io.Writer; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.io.PrintWriter; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.util.Locale; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
9 import de.intevation.artifacts.CallMeta; |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
10 |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.model.WQ; |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
12 import de.intevation.flys.artifacts.resources.Resources; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
14 import org.apache.commons.math.analysis.UnivariateRealFunction; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
16 import org.apache.commons.math.analysis.interpolation.SplineInterpolator; |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
17 import org.apache.commons.math.analysis.interpolation.LinearInterpolator; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
19 import org.apache.commons.math.analysis.polynomials.PolynomialFunction; |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
20 |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
21 import org.apache.commons.math.FunctionEvaluationException; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 import org.apache.log4j.Logger; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public class ATWriter |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 private static Logger logger = Logger.getLogger(ATWriter.class); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public static final int COLUMNS = 10; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
31 public static final String I18N_AT_HEADER = |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
32 "export.discharge.curve.at.header"; |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
33 |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
34 public static final String EMPTY = " "; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 protected double minW; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 protected double maxW; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 protected double minQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 protected double maxQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
41 protected UnivariateRealFunction qFunc; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public ATWriter() { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 public ATWriter(WQ wq) throws IllegalArgumentException { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
1033
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
48 int [] bounds = wq.longestIncreasingWRangeIndices(); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
1033
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
50 if (logger.isDebugEnabled()) { |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
51 logger.debug("exporting w between indices " + |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
52 bounds[0] + " and " + bounds[1] + " (" + |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
53 wq.getW(bounds[0]) + ", " + wq.getW(bounds[1])); |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
54 } |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
55 |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
56 if (bounds[1]-bounds[0] < 1) { // Only first w can be written out. |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
57 minW = maxW = wq.getW(bounds[0]); |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
58 minQ = maxQ = wq.getQ(bounds[0]); |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
59 // constant function |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
60 qFunc = new PolynomialFunction(new double [] { minQ }); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 return; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
1033
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
64 double [] ws = new double[bounds[1]-bounds[0]]; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 double [] qs = new double[ws.length]; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 for (int i = 0; i < ws.length; ++i) { |
1033
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
68 int idx = bounds[0]+i; |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
69 ws[i] = wq.getW(idx); |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
70 qs[i] = wq.getQ(idx); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
73 qFunc = ws.length < 3 |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
74 ? new LinearInterpolator().interpolate(ws, qs) |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
75 : new SplineInterpolator().interpolate(ws, qs); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 |
1033
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
77 minW = wq.getW(bounds[0]); |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
78 maxW = wq.getW(bounds[1]); |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
79 minQ = wq.getQ(bounds[0]); |
821aaceb2776
Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
747
diff
changeset
|
80 maxQ = wq.getQ(bounds[1]); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 public double getQ(double w) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 try { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 return qFunc.value(w); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 } |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
88 catch (FunctionEvaluationException aode) { |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 // should not happen |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 logger.warn("spline interpolation failed", aode); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 return w <= minW ? minQ : maxQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 |
3220
0c8a6145098b
FixA: Added AT writer for fitted functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1682
diff
changeset
|
95 public static void printQ(PrintWriter out, double q) { |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 String format; |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
97 if (q < 1d) format = " % 8.3f"; |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
98 else if (q < 10d) format = " % 8.2f"; |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
99 else if (q < 100d) format = " % 8.1f"; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 else { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 format = " % 8.0f"; |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
102 if (q > 1000d) q = Math.rint(q/10d)*10d; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 out.printf(Locale.US, format, q); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
108 protected static void printHeader( |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
109 PrintWriter out, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
110 CallMeta callMeta, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
111 String river, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
112 double km |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
113 ) { |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
114 out.println(Resources.getMsg( |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
115 callMeta, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
116 I18N_AT_HEADER, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
117 I18N_AT_HEADER, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
118 new Object[] { river, km } )); |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
119 } |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
120 |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
121 |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
122 public void write(Writer writer, CallMeta meta, String river, double km) |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
123 throws IOException |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
124 { |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 PrintWriter out = new PrintWriter(writer); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
127 // a header is required, because the desktop version of FLYS will skip |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
128 // the first row. |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
129 printHeader(out, meta, river, km); |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1033
diff
changeset
|
130 |
1682
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
131 double rest = (minW * 100.0) % 10.0; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 |
1682
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
133 double startW = Math.rint((minW - rest*0.01)*10.0)*0.1; |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
134 |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
135 if (logger.isDebugEnabled()) { |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
136 logger.debug("startW: " + startW); |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
137 logger.debug("rest: " + rest); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 int col = 0; |
732
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
141 for (double w = startW; w <= maxW; w += 0.01) { |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
142 if (col == 0) { |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
143 out.printf(Locale.US, "%8d", (int)Math.round(w*100.0)); |
39d191f011dc
ATWriter: Results are now in cm. Made it more robust against corner cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
729
diff
changeset
|
144 } |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 |
1682
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
146 if (w < minW) { |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
147 out.print(EMPTY); |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
148 } |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
149 else { |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
150 printQ(out, getQ(w)); |
394b7ac58fc9
ATWriter: Get rid of buggy first line code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
151 } |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 if (++col >= COLUMNS) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 out.println(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 col = 0; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 if (col > 0) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 out.println(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 out.flush(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |