Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java @ 8362:839032ac1523
Purge obsolete representation of reference system for discharge tables.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 01 Oct 2014 15:54:47 +0200 |
parents | e4606eae8ea5 |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8361:c494f9a61490 | 8362:839032ac1523 |
---|---|
43 public static final String I18N_AT_HEADER = | 43 public static final String I18N_AT_HEADER = |
44 "export.discharge.curve.at.header"; | 44 "export.discharge.curve.at.header"; |
45 | 45 |
46 public static final String I18N_AT_GAUGE_HEADER = | 46 public static final String I18N_AT_GAUGE_HEADER = |
47 "export.discharge.curve.at.gauge.header"; | 47 "export.discharge.curve.at.gauge.header"; |
48 | |
49 public static final String I18N_AT_CALC_GAUGE_HEADER = | |
50 "export.discharge.curve.at.gauge.calc.header"; | |
51 | 48 |
52 public static final String EMPTY = " "; | 49 public static final String EMPTY = " "; |
53 | 50 |
54 public static double getQ(int w, UnivariateRealFunction qFunc) { | 51 public static double getQ(int w, UnivariateRealFunction qFunc) { |
55 try { | 52 try { |
71 else { | 68 else { |
72 format = " % 8.0f"; | 69 format = " % 8.0f"; |
73 if (q > 1000d) q = Math.rint(q/10d)*10d; | 70 if (q > 1000d) q = Math.rint(q/10d)*10d; |
74 } | 71 } |
75 out.printf(Locale.US, format, q); | 72 out.printf(Locale.US, format, q); |
76 } | |
77 | |
78 protected static void printCalculatedGaugeHeader( | |
79 PrintWriter out, | |
80 CallMeta callMeta, | |
81 String river, | |
82 double km, | |
83 String gName, | |
84 BigDecimal datum, | |
85 Date date, | |
86 String unit | |
87 ) { | |
88 out.print("*" + Resources.getMsg( | |
89 callMeta, | |
90 I18N_AT_CALC_GAUGE_HEADER, | |
91 I18N_AT_CALC_GAUGE_HEADER, | |
92 new Object[] { river, gName, datum, unit } )); | |
93 out.print("\r\n"); | |
94 } | 73 } |
95 | 74 |
96 protected static void printGaugeHeader( | 75 protected static void printGaugeHeader( |
97 PrintWriter out, | 76 PrintWriter out, |
98 CallMeta callMeta, | 77 CallMeta callMeta, |
146 | 125 |
147 UnivariateRealFunction qFunc; | 126 UnivariateRealFunction qFunc; |
148 | 127 |
149 WQ wq = WQ.getFixedWQforExportAtGauge(values, datum); | 128 WQ wq = WQ.getFixedWQforExportAtGauge(values, datum); |
150 | 129 |
151 // If we converted to centimeter we know that the WQ table is | |
152 // calculated because of the assumption that all calculations | |
153 // are in Meter and only the discharge tables data is in meter. | |
154 boolean isCalculation = wq.getReferenceSystem() != values.getReferenceSystem(); | |
155 | |
156 int [] bounds = wq.longestIncreasingWRangeIndices(); | 130 int [] bounds = wq.longestIncreasingWRangeIndices(); |
157 | |
158 if (log.isDebugEnabled()) { | |
159 log.debug("exporting " + (isCalculation ? "calculated " : "") + | |
160 "w between indices " + bounds[0] + " and " + bounds[1] + " (" + | |
161 (int)Math.ceil(wq.getW(bounds[0])) + ", " + | |
162 (int)Math.floor(wq.getW(bounds[1]))+ ")"); | |
163 } | |
164 | 131 |
165 if (bounds[1]-bounds[0] < 1) { // Only first w can be written out. | 132 if (bounds[1]-bounds[0] < 1) { // Only first w can be written out. |
166 minW = maxW = (int)Math.round(wq.getW(bounds[0])); | 133 minW = maxW = (int)Math.round(wq.getW(bounds[0])); |
167 minQ = maxQ = wq.getQ(bounds[0]); | 134 minQ = maxQ = wq.getQ(bounds[0]); |
168 // constant function | 135 // constant function |
193 PrintWriter out = new PrintWriter(writer); | 160 PrintWriter out = new PrintWriter(writer); |
194 | 161 |
195 // A header is required, because the desktop version of FLYS will skip | 162 // A header is required, because the desktop version of FLYS will skip |
196 // the first row. | 163 // the first row. |
197 if (gName != null) { | 164 if (gName != null) { |
198 if (isCalculation) { | 165 printGaugeHeader(out, meta, river, km, gName, datum, date, unit); |
199 printCalculatedGaugeHeader(out, meta, river, km, gName, datum, date, unit); | |
200 } else { | |
201 printGaugeHeader(out, meta, river, km, gName, datum, date, unit); | |
202 } | |
203 } | 166 } |
204 else { | 167 else { |
205 printHeader(out, meta, river, km); | 168 printHeader(out, meta, river, km); |
206 } | 169 } |
207 | 170 |