Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java @ 8884:7a8c12706834
Work on SINFO-FlowDepth
author | gernotbelger |
---|---|
date | Tue, 13 Feb 2018 14:53:23 +0100 |
parents | f762fadc5313 |
children | a66f2a7c4f84 |
comparison
equal
deleted
inserted
replaced
8883:a536e1aacf0f | 8884:7a8c12706834 |
---|---|
98 | 98 |
99 private static final String CSV_META_HEADER_WATERLEVEL = "sinfo.export.flow_depth.csv.meta.header.waterlevel"; | 99 private static final String CSV_META_HEADER_WATERLEVEL = "sinfo.export.flow_depth.csv.meta.header.waterlevel"; |
100 | 100 |
101 private static final String CSV_META_HEADER_WATERLEVEL_NAME = "sinfo.export.flow_depth.csv.meta.header.waterlevel.name"; | 101 private static final String CSV_META_HEADER_WATERLEVEL_NAME = "sinfo.export.flow_depth.csv.meta.header.waterlevel.name"; |
102 | 102 |
103 | |
104 private static final String CSV_META_HEADER_WATERLEVEL_GAUGE = "sinfo.export.flow_depth.csv.meta.header.waterlevel.gauge"; | 103 private static final String CSV_META_HEADER_WATERLEVEL_GAUGE = "sinfo.export.flow_depth.csv.meta.header.waterlevel.gauge"; |
105 | 104 |
106 private static final String CSV_META_HEADER_WATERLEVEL_YEAR = "sinfo.export.flow_depth.csv.meta.header.waterlevel.year"; | 105 private static final String CSV_META_HEADER_WATERLEVEL_YEAR = "sinfo.export.flow_depth.csv.meta.header.waterlevel.year"; |
107 | 106 |
108 private static final String CSV_META_RANGE = "sinfo.export.flow_depth.csv.meta.range"; | 107 private static final String CSV_META_RANGE = "sinfo.export.flow_depth.csv.meta.range"; |
161 for (final FlowDepthCalculationResult result : results.getResults()) { | 160 for (final FlowDepthCalculationResult result : results.getResults()) { |
162 writeCSVFlowDepthResult(writer, result, useTkh); | 161 writeCSVFlowDepthResult(writer, result, useTkh); |
163 } | 162 } |
164 } | 163 } |
165 | 164 |
166 private void writeCSVFlowDepthResult(final CSVWriter writer, final FlowDepthCalculationResult result, | 165 private void writeCSVFlowDepthResult(final CSVWriter writer, final FlowDepthCalculationResult result, final boolean useTkh) { |
167 final boolean useTkh) { | |
168 | 166 |
169 /* first some specific metadata */ | 167 /* first some specific metadata */ |
170 final BedHeightInfo sounding = result.getSounding(); | 168 final BedHeightInfo sounding = result.getSounding(); |
171 final WstInfo wst = result.getWst(); | 169 final WstInfo wst = result.getWst(); |
172 | 170 |
182 // "# Lagesystem: " | 180 // "# Lagesystem: " |
183 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_PRJ, sounding.getLocationSystem()); | 181 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_PRJ, sounding.getLocationSystem()); |
184 // "# Höhensystem: " | 182 // "# Höhensystem: " |
185 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL, sounding.getCurElevationModelUnit()); | 183 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL, sounding.getCurElevationModelUnit()); |
186 // "# ursprüngliches Höhensystem: " | 184 // "# ursprüngliches Höhensystem: " |
187 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL, | 185 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL, sounding.getOldElevationModelUnit()); |
188 sounding.getOldElevationModelUnit()); | |
189 | 186 |
190 // "##METADATEN WASSERSPIEGELLAGE" | 187 // "##METADATEN WASSERSPIEGELLAGE" |
191 writeCSVMetaEntry(writer, CSV_META_HEADER_WATERLEVEL); | 188 writeCSVMetaEntry(writer, CSV_META_HEADER_WATERLEVEL); |
192 // "# Bezeichnung der Wasserspiegellage: " | 189 // "# Bezeichnung der Wasserspiegellage: " |
193 writeCSVMetaEntry(writer, CSV_META_HEADER_WATERLEVEL_NAME, wst.getLabel()); | 190 writeCSVMetaEntry(writer, CSV_META_HEADER_WATERLEVEL_NAME, wst.getLabel()); |
206 private void writeCSVMeta(final CSVWriter writer, final FlowDepthCalculationResults results) { | 203 private void writeCSVMeta(final CSVWriter writer, final FlowDepthCalculationResults results) { |
207 log.info("FlowDepthExporter.writeCSVMeta"); | 204 log.info("FlowDepthExporter.writeCSVMeta"); |
208 | 205 |
209 final String calcModeLabel = results.getCalcModeLabel(); | 206 final String calcModeLabel = results.getCalcModeLabel(); |
210 final River river = results.getRiver(); | 207 final River river = results.getRiver(); |
211 writeCSVMetaEntry(writer, CSV_META_HEADER_RESULT, msg(CSV_META_HEADER_RESULT_LABEL), river.getName(), | 208 writeCSVMetaEntry(writer, CSV_META_HEADER_RESULT, msg(CSV_META_HEADER_RESULT_LABEL), river.getName(), calcModeLabel); |
212 calcModeLabel); | |
213 | 209 |
214 // "# FLYS-Version: " | 210 // "# FLYS-Version: " |
215 writeCSVMetaEntry(writer, CSV_META_VERSION, msg(CSV_META_VERSION_LABEL), FLYS.VERSION); | 211 writeCSVMetaEntry(writer, CSV_META_VERSION, msg(CSV_META_VERSION_LABEL), FLYS.VERSION); |
216 | 212 |
217 // "# Bearbeiter: " | 213 // "# Bearbeiter: " |
300 // Wasserstand [NN + m] | 296 // Wasserstand [NN + m] |
301 lines.add(getW2Formatter().format(row.getWaterlevel())); | 297 lines.add(getW2Formatter().format(row.getWaterlevel())); |
302 | 298 |
303 // Q [m³/s] | 299 // Q [m³/s] |
304 final double discharge = row.getDischarge(); | 300 final double discharge = row.getDischarge(); |
305 if( Double.isNaN(discharge)) | 301 if (Double.isNaN(discharge)) |
306 lines.add(StringUtils.EMPTY); | 302 lines.add(StringUtils.EMPTY); |
307 else | 303 else { |
308 { | |
309 final double roundedDischarge = RiverUtils.roundQ(discharge); | 304 final double roundedDischarge = RiverUtils.roundQ(discharge); |
310 lines.add(getQFormatter().format(roundedDischarge)); | 305 lines.add(getQFormatter().format(roundedDischarge)); |
311 } | 306 } |
312 | 307 |
313 // Bezeichnung | 308 // Bezeichnung |
400 source.addMetaData("date", df.format(new Date())); | 395 source.addMetaData("date", df.format(new Date())); |
401 | 396 |
402 source.addMetaData("river_label", msg(CSV_META_RIVER_LABEL)); | 397 source.addMetaData("river_label", msg(CSV_META_RIVER_LABEL)); |
403 source.addMetaData("river", river.getName()); | 398 source.addMetaData("river", river.getName()); |
404 | 399 |
405 final String rangeValue = String.format("%s - %s", getKmFormatter().format(results.getFrom()), | 400 final String rangeValue = String.format("%s - %s", getKmFormatter().format(results.getFrom()), getKmFormatter().format(results.getTo())); |
406 getKmFormatter().format(results.getTo())); | |
407 source.addMetaData("range_label", msg(CSV_META_RANGE_LABEL)); | 401 source.addMetaData("range_label", msg(CSV_META_RANGE_LABEL)); |
408 source.addMetaData("range", rangeValue); | 402 source.addMetaData("range", rangeValue); |
409 | 403 |
410 /* column headings */ | 404 /* column headings */ |
411 source.addMetaData("station_header", msg(CSV_KM_HEADER)); | 405 source.addMetaData("station_header", msg(CSV_KM_HEADER)); |
420 source.addMetaData("bedheight_header", msg(CSV_MEAN_BED_HEIGHT_HEADER_SHORT)); | 414 source.addMetaData("bedheight_header", msg(CSV_MEAN_BED_HEIGHT_HEADER_SHORT)); |
421 source.addMetaData("sounding_name_header", msg(CSV_SOUNDING_HEADER)); | 415 source.addMetaData("sounding_name_header", msg(CSV_SOUNDING_HEADER)); |
422 source.addMetaData("location_header", msg(CSV_LOCATION_HEADER)); | 416 source.addMetaData("location_header", msg(CSV_LOCATION_HEADER)); |
423 } | 417 } |
424 | 418 |
425 private void addJRTableData(final MetaAndTableJRDataSource source, final FlowDepthCalculationResult result, | 419 private void addJRTableData(final MetaAndTableJRDataSource source, final FlowDepthCalculationResult result, final boolean useTkh) { |
426 final boolean useTkh) { | |
427 | 420 |
428 final Collection<FlowDepthRow> rows = result.getRows(); | 421 final Collection<FlowDepthRow> rows = result.getRows(); |
429 | 422 |
430 for (final FlowDepthRow row : rows) { | 423 for (final FlowDepthRow row : rows) { |
431 | 424 |