Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java @ 8954:183f42641ab6
Fixed: flowd depth calculation without transport bodies heights did not work any more
author | gernotbelger |
---|---|
date | Mon, 19 Mar 2018 14:13:37 +0100 |
parents | 09e4a4909814 |
children | d5802f22e4f5 |
comparison
equal
deleted
inserted
replaced
8953:c40db8e8dcae | 8954:183f42641ab6 |
---|---|
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
29 * @author Gernot Belger | 29 * @author Gernot Belger |
30 */ | 30 */ |
31 // REMARK: must be public because its registered in generators.xml | 31 // REMARK: must be public because its registered in generators.xml |
32 public class FlowDepthExporter extends AbstractSInfoExporter<FlowDepthCalculationResult, FlowDepthCalculationResults> { | 32 public class FlowDepthExporter extends AbstractSInfoExporter<FlowDepthCalculationResult, FlowDepthCalculationResults> { |
33 | |
34 private static enum ExportMode { | |
35 pdf, csv | |
36 } | |
33 | 37 |
34 /** The log used in this exporter. */ | 38 /** The log used in this exporter. */ |
35 private static Logger log = Logger.getLogger(FlowDepthExporter.class); | 39 private static Logger log = Logger.getLogger(FlowDepthExporter.class); |
36 | 40 |
37 private static final String JASPER_FILE = "/jasper/sinfo.flowdepth.jasper"; | 41 private static final String JASPER_FILE = "/jasper/sinfo.flowdepth.jasper"; |
92 writer.writeNext(header.toArray(new String[header.size()])); | 96 writer.writeNext(header.toArray(new String[header.size()])); |
93 } | 97 } |
94 | 98 |
95 @Override | 99 @Override |
96 protected String[] formatCSVRow(final FlowDepthCalculationResults results, final FlowDepthCalculationResult result, final SInfoResultRow row) { | 100 protected String[] formatCSVRow(final FlowDepthCalculationResults results, final FlowDepthCalculationResult result, final SInfoResultRow row) { |
97 return formatRow(row); | 101 return formatRow(row, ExportMode.csv); |
98 } | 102 } |
99 | 103 |
100 /** | 104 /** |
101 * Format a row of a flow depth result into an array of string, both used by csv and pdf | 105 * Format a row of a flow depth result into an array of string, both used by csv and pdf |
102 * | 106 * |
107 * @param pdf | |
108 * | |
103 * @param useTkh | 109 * @param useTkh |
104 */ | 110 */ |
105 private String[] formatRow(final SInfoResultRow row) { | 111 private String[] formatRow(final SInfoResultRow row, final ExportMode mode) { |
106 | 112 |
107 final Collection<String> lines = new ArrayList<>(11); | 113 final Collection<String> lines = new ArrayList<>(11); |
108 | 114 |
109 lines.add(row.exportValue(this.context, SInfoResultType.station)); | 115 lines.add(row.exportValue(this.context, SInfoResultType.station)); |
110 lines.add(row.exportValue(this.context, SInfoResultType.flowdepth)); | 116 lines.add(row.exportValue(this.context, SInfoResultType.flowdepth)); |
111 | 117 |
112 if (getData().isUseTkh()) { | 118 if (mode == ExportMode.pdf || getData().isUseTkh()) { |
113 lines.add(row.exportValue(this.context, SInfoResultType.flowdepthtkh)); | 119 lines.add(row.exportValue(this.context, SInfoResultType.flowdepthtkh)); |
114 lines.add(row.exportValue(this.context, SInfoResultType.tkh)); | 120 lines.add(row.exportValue(this.context, SInfoResultType.tkh)); |
115 } | 121 } |
116 | 122 |
117 lines.add(row.exportValue(this.context, SInfoResultType.waterlevel)); | 123 lines.add(row.exportValue(this.context, SInfoResultType.waterlevel)); |
150 source.addMetaData("location_header", SInfoResultType.location.getPdfHeader(this.context.getMeta())); | 156 source.addMetaData("location_header", SInfoResultType.location.getPdfHeader(this.context.getMeta())); |
151 } | 157 } |
152 | 158 |
153 @Override | 159 @Override |
154 protected String[] formatPDFRow(final FlowDepthCalculationResults results, final SInfoResultRow row) { | 160 protected String[] formatPDFRow(final FlowDepthCalculationResults results, final SInfoResultRow row) { |
155 return formatRow(row); | 161 return formatRow(row, ExportMode.pdf); |
156 } | 162 } |
157 } | 163 } |