Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java @ 1658:7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
flys-artifacts/trunk@2856 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 28 Sep 2011 15:02:33 +0000 |
parents | 821aaceb2776 |
children | a800994aed1e |
comparison
equal
deleted
inserted
replaced
1657:91d038c7aae5 | 1658:7d11ad5a52d5 |
---|---|
4 import java.io.Writer; | 4 import java.io.Writer; |
5 import java.io.PrintWriter; | 5 import java.io.PrintWriter; |
6 | 6 |
7 import java.util.Locale; | 7 import java.util.Locale; |
8 | 8 |
9 import de.intevation.artifacts.CallMeta; | |
10 | |
9 import de.intevation.flys.artifacts.model.WQ; | 11 import de.intevation.flys.artifacts.model.WQ; |
12 import de.intevation.flys.artifacts.resources.Resources; | |
10 | 13 |
11 import org.apache.commons.math.analysis.UnivariateRealFunction; | 14 import org.apache.commons.math.analysis.UnivariateRealFunction; |
12 | 15 |
13 import org.apache.commons.math.analysis.interpolation.SplineInterpolator; | 16 import org.apache.commons.math.analysis.interpolation.SplineInterpolator; |
14 import org.apache.commons.math.analysis.interpolation.LinearInterpolator; | 17 import org.apache.commons.math.analysis.interpolation.LinearInterpolator; |
22 public class ATWriter | 25 public class ATWriter |
23 { | 26 { |
24 private static Logger logger = Logger.getLogger(ATWriter.class); | 27 private static Logger logger = Logger.getLogger(ATWriter.class); |
25 | 28 |
26 public static final int COLUMNS = 10; | 29 public static final int COLUMNS = 10; |
30 | |
31 public static final String I18N_AT_HEADER = | |
32 "export.discharge.curve.at.header"; | |
27 | 33 |
28 public static final String EMPTY = " "; | 34 public static final String EMPTY = " "; |
29 | 35 |
30 protected double minW; | 36 protected double minW; |
31 protected double maxW; | 37 protected double maxW; |
96 if (q > 1000d) q = Math.rint(q/10d)*10d; | 102 if (q > 1000d) q = Math.rint(q/10d)*10d; |
97 } | 103 } |
98 out.printf(Locale.US, format, q); | 104 out.printf(Locale.US, format, q); |
99 } | 105 } |
100 | 106 |
101 public void write(Writer writer) throws IOException { | |
102 | 107 |
108 protected static void printHeader( | |
109 PrintWriter out, | |
110 CallMeta callMeta, | |
111 String river, | |
112 double km | |
113 ) { | |
114 out.println(Resources.getMsg( | |
115 callMeta, | |
116 I18N_AT_HEADER, | |
117 I18N_AT_HEADER, | |
118 new Object[] { river, km } )); | |
119 } | |
120 | |
121 | |
122 public void write(Writer writer, CallMeta meta, String river, double km) | |
123 throws IOException | |
124 { | |
103 PrintWriter out = new PrintWriter(writer); | 125 PrintWriter out = new PrintWriter(writer); |
126 | |
127 // a header is required, because the desktop version of FLYS will skip | |
128 // the first row. | |
129 printHeader(out, meta, river, km); | |
104 | 130 |
105 double rest = Math.abs(minW % COLUMNS); | 131 double rest = Math.abs(minW % COLUMNS); |
106 | 132 |
107 double startW = Math.round(minW*10.0)/10.0; | 133 double startW = Math.round(minW*10.0)/10.0; |
108 if (rest >= 1d) { | 134 if (rest >= 1d) { |