comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java @ 9205:3dae6b78e1da

inundationDuration/floodDuration multiple columns+chartLines refactoring
author gernotbelger
date Mon, 02 Jul 2018 19:01:09 +0200
parents 0a19a79663dd
children 740d65e4aa14
comparison
equal deleted inserted replaced
9204:4f411c6ee3ae 9205:3dae6b78e1da
154 final boolean showAllGauges = false; 154 final boolean showAllGauges = false;
155 final WaterlevelData waterlevel = new WaterlevelData(wkms, wspYear, showAllGauges); 155 final WaterlevelData waterlevel = new WaterlevelData(wkms, wspYear, showAllGauges);
156 156
157 final RiverInfoProvider riverInfoProvider = riverInfo.forWaterlevel(waterlevel); 157 final RiverInfoProvider riverInfoProvider = riverInfo.forWaterlevel(waterlevel);
158 158
159 // FIXME: check with winfo how the name is generated 159 final String waterlevelLabel = descBuilder.getDesc(wkms);
160 final String wstLabel = waterlevel.getName(); 160
161 161 final WstInfo wstInfo = new WstInfo(waterlevelLabel, wspYear, riverInfoProvider.getReferenceGauge());
162 final WstInfo wstInfo = new WstInfo(wstLabel, wspYear, riverInfoProvider.getReferenceGauge());
163 162
164 /* build tkh calculators per bedheight */ 163 /* build tkh calculators per bedheight */
165 final Map<NumberRange, TkhCalculator> calculatorsByRanges = buildCalculators(calcRange, wkms, bedHeights, problems, riverInfoProvider, wstLabel); 164 final Map<NumberRange, TkhCalculator> calculatorsByRanges = buildCalculators(calcRange, wkms, bedHeights, problems, riverInfoProvider, waterlevelLabel);
166 if (calculatorsByRanges.isEmpty()) { 165 if (calculatorsByRanges.isEmpty()) {
167 /* there should already be some problems, so just abort */ 166 /* there should already be some problems, so just abort */
168 return null; 167 return null;
169 } 168 }
170 169
171 final Collection<ResultRow> rows = new ArrayList<>(); 170 final Collection<ResultRow> rows = new ArrayList<>();
172
173 final String waterlevelLabel = descBuilder.getDesc(wkms);
174 171
175 for (final Double stationDbl : allStations) { 172 for (final Double stationDbl : allStations) {
176 173
177 final double station = stationDbl; 174 final double station = stationDbl;
178 175
189 186
190 if (tkhCalculator.calculateTkh(station, row)) 187 if (tkhCalculator.calculateTkh(station, row))
191 rows.add(row); 188 rows.add(row);
192 } 189 }
193 190
194 return new TkhCalculationResult(wstLabel, wstInfo, true, rows); 191 return new TkhCalculationResult(waterlevelLabel, wstInfo, true, rows);
195 } 192 }
196 193
197 private TkhCalculator findCalculator(final Map<NumberRange, TkhCalculator> calculators, final double station) { 194 private TkhCalculator findCalculator(final Map<NumberRange, TkhCalculator> calculators, final double station) {
198 195
199 // REMAKR: linear search at this point, put we expect the number of bed heights to be very small (1-2 items) 196 // REMAKR: linear search at this point, put we expect the number of bed heights to be very small (1-2 items)

http://dive4elements.wald.intevation.org