Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java @ 1013:73330e89b0af
Minor cosmetics, (comments).
flys-artifacts/trunk@2459 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 03 Aug 2011 11:20:07 +0000 |
parents | 65dcb5891206 |
children | 821aaceb2776 |
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 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.artifacts.model.WQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
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
|
11 import org.apache.commons.math.analysis.UnivariateRealFunction; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
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
|
13 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
|
14 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
|
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.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
|
17 |
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
|
18 import org.apache.commons.math.FunctionEvaluationException; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 public class ATWriter |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 private static Logger logger = Logger.getLogger(ATWriter.class); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 public static final int COLUMNS = 10; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
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
|
28 public static final String EMPTY = " "; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 protected double minW; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 protected double maxW; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 protected double minQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 protected double maxQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
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
|
35 protected UnivariateRealFunction qFunc; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public ATWriter() { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public ATWriter(WQ wq) throws IllegalArgumentException { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 int maxIndex = maxIncreasingWIndex(wq); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 if (maxIndex < 1) { // Only first w can be written out. |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 minW = maxW = wq.getW(0); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 minQ = maxQ = wq.getQ(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
|
47 // 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
|
48 qFunc = new PolynomialFunction(new double [] { minQ }); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 return; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
747
65dcb5891206
ATWriter: Fixed array size to construct spline with stricly increasing values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
732
diff
changeset
|
52 double [] ws = new double[maxIndex]; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 double [] qs = new double[ws.length]; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 for (int i = 0; i < ws.length; ++i) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 ws[i] = wq.getW(i); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 qs[i] = wq.getQ(i); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 |
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
|
60 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
|
61 ? 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
|
62 : new SplineInterpolator().interpolate(ws, qs); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 minW = wq.getW(0); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 maxW = wq.getW(maxIndex); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 minQ = wq.getQ(0); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 maxQ = wq.getQ(maxIndex); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 public static int maxIncreasingWIndex(WQ wq) { |
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 int N = wq.size(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 if (N < 2) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 return N-1; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 double last = wq.getW(0); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 for (int i = 1; i < N; ++i) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 double current = wq.getW(i); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 if (current <= last) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 return i-1; |
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 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 return N-1; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 public double getQ(double w) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 try { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 return qFunc.value(w); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
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
|
95 catch (FunctionEvaluationException aode) { |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 // should not happen |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 logger.warn("spline interpolation failed", aode); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 return w <= minW ? minQ : maxQ; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 protected static void printQ(PrintWriter out, double q) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 else if (q < 100d) format = " % 8.1f"; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 else { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 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
|
109 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
|
110 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 out.printf(Locale.US, format, q); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 public void write(Writer writer) throws IOException { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 PrintWriter out = new PrintWriter(writer); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 |
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
|
118 double rest = Math.abs(minW % COLUMNS); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 int columns = (int)Math.floor(rest); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 for (int i = columns; i < COLUMNS; ++i) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 out.print(EMPTY); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 } |
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
|
128 for (int i = COLUMNS-columns; i < COLUMNS; ++i) { |
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
|
129 printQ(out, getQ(startW + i*0.01)); |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
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 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
|
132 startW += 0.1; |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 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
|
136 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
|
137 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
|
138 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
|
139 } |
729
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 printQ(out, getQ(w)); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 if (++col >= COLUMNS) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 out.println(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 col = 0; |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 if (col > 0) { |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 out.println(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 } |
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 out.flush(); |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 } |
078934923acb
New AT writer for results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |