Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java @ 1663:4fbd43061315
Show proper labels for selected differences.
flys-artifacts/trunk@2866 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 30 Sep 2011 05:31:34 +0000 |
parents | a800994aed1e |
children | 394b7ac58fc9 |
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 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 protected static void printQ(PrintWriter out, double q) { |
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 |
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
|
131 double rest = Math.abs(minW % COLUMNS); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 |
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
|
133 double startW = Math.round(minW*10.0)/10.0; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 if (rest >= 1d) { |
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
|
135 startW -= 0.1; |
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
|
136 out.printf(Locale.US, "%8d", (int)Math.round(startW*100.0)); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 int columns = (int)Math.floor(rest); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 for (int i = columns; i < COLUMNS; ++i) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 out.print(EMPTY); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
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 (int i = COLUMNS-columns; i < COLUMNS; ++i) { |
1662
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
142 double w = startW + i*0.01; |
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
143 if (w < minW) { |
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
144 out.print(EMPTY); |
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
145 } |
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
146 else { |
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
147 printQ(out, getQ(w)); |
a800994aed1e
Fixed issues flys/issue244, flys/issue332
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1658
diff
changeset
|
148 } |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 } |
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
|
150 out.println(); |
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
|
151 startW += 0.1; |
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 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 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
|
158 } |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 printQ(out, getQ(w)); |
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 if (++col >= COLUMNS) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 out.println(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 col = 0; |
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 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 if (col > 0) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 out.println(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 out.flush(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |