comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java @ 9492:10530f1d7dd5

Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
author gernotbelger
date Thu, 20 Sep 2018 14:00:30 +0200
parents 5ce50640688c
children aa6ee96071b7
comparison
equal deleted inserted replaced
9491:d7d22ea8573d 9492:10530f1d7dd5
53 } 53 }
54 } 54 }
55 55
56 private static final long serialVersionUID = 1L; 56 private static final long serialVersionUID = 1L;
57 57
58 private final boolean isUseWspl;
59
58 private final String[] waterlevelLabels; 60 private final String[] waterlevelLabels;
59 61
60 private final int maxWaterlevelPdf = 3; 62 private final int maxWaterlevelPdf = 3;
61 63
62 public interface ValueGetter { 64 public interface ValueGetter {
65 67
66 private enum ExportMode { 68 private enum ExportMode {
67 pdf, csv 69 pdf, csv
68 } 70 }
69 71
70 public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows) { 72 public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows, final boolean isUseWspl) {
71 super(label, rows); 73 super(label, rows);
72 this.waterlevelLabels = mainvalueLabels; 74 this.waterlevelLabels = mainvalueLabels;
75 this.isUseWspl = isUseWspl;
73 } 76 }
74 77
75 /** 78 /**
76 * Collection of the result rows containing only the rows describing an infrastructure 79 * Collection of the result rows containing only the rows describing an infrastructure
77 */ 80 */
110 return "/jasper/templates/sinfo.floodduration2.jrxml"; 113 return "/jasper/templates/sinfo.floodduration2.jrxml";
111 } 114 }
112 115
113 protected String[] formatRow(final AbstractExportContext exportContextCSV, final ResultRow row, final ExportMode mode) { 116 protected String[] formatRow(final AbstractExportContext exportContextCSV, final ResultRow row, final ExportMode mode) {
114 117
115 final Collection<String> lines = new ArrayList<>(10); 118 final Collection<String> lines = new ArrayList<>(20);
116 119
117 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); 120 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station));
118 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.riverside)); 121 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.riverside));
119 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDuration)); 122 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDuration));
120 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge)); 123 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge));
121 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight)); 124 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight));
122 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype)); 125 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype));
123 126
124 final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); 127 final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel);
125 if (waterlevelList != null) { 128
126 final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter(); 129 final int expectedSizetoGaugelabel = lines.size() + (waterlevelList.size() < 2 ? 4 : 12); // removing columns only works for fixed
127 final NumberFormat qFormatter = exportContextCSV.getQFormatter(); 130 // indices
128 final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter(); 131
129 132 final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter();
130 for (int i = 0; i < waterlevelList.size(); i++) { 133 final NumberFormat qFormatter = exportContextCSV.getQFormatter();
131 134 final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter();
132 if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf) 135
133 break; 136 for (int i = 0; i < waterlevelList.size(); i++) {
134 137
135 final DurationWaterlevel item = waterlevelList.get(i); 138 if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf)
136 lines.add(item.getWFormatted(wFormatter)); 139 break;
137 lines.add(item.getFloodDurDaysPerYearFormatted(durFormatter)); 140
138 lines.add(item.getQFormatted(qFormatter)); 141 final DurationWaterlevel item = waterlevelList.get(i);
139 lines.add(item.getBezeichnung()); 142 lines.add(item.getWFormatted(wFormatter));
140 } 143 lines.add(item.getFloodDurDaysPerYearFormatted(durFormatter));
141 } 144 lines.add(item.getQFormatted(qFormatter));
142 145 lines.add(item.getBezeichnung());
143 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); 146 }
147
148 final int lineSize = lines.size();
149 while (mode == ExportMode.pdf && lines.size() < expectedSizetoGaugelabel)
150 lines.add("");
151
152 if (isUseWspl() || mode == ExportMode.pdf)
153 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); // PDF: necessary, because if removed, location would not be shown!
154
144 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); 155 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location));
145 156
146 return lines.toArray(new String[lines.size()]); 157 return lines.toArray(new String[lines.size()]);
147 } 158 }
148 159
167 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderFloodDurPerYearCsv(), appendIndex)); 178 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderFloodDurPerYearCsv(), appendIndex));
168 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderQ(), appendIndex)); 179 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderQ(), appendIndex));
169 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderBezeichnCsv(), appendIndex)); 180 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderBezeichnCsv(), appendIndex));
170 } 181 }
171 182
172 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); 183 if (isUseWspl())
184 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel));
185
173 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); 186 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location));
174 187
175 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); 188 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
176 } 189 }
177 190
263 yPoints.add(value); 276 yPoints.add(value);
264 } 277 }
265 278
266 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; 279 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() };
267 } 280 }
281
282 public boolean isUseWspl() {
283 return this.isUseWspl;
284 }
268 } 285 }

http://dive4elements.wald.intevation.org