9145
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by |
|
3 * Björnsen Beratende Ingenieure GmbH |
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
|
5 * |
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
8 * documentation coming with Dive4Elements River for details. |
|
9 */ |
|
10 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
|
11 |
|
12 import java.util.ArrayList; |
|
13 import java.util.Collection; |
|
14 import java.util.List; |
|
15 |
|
16 import org.apache.commons.lang.math.DoubleRange; |
|
17 import org.dive4elements.river.artifacts.common.GeneralResultType; |
|
18 import org.dive4elements.river.artifacts.common.ResultRow; |
|
19 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; |
|
20 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
|
21 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; |
|
22 |
|
23 /** |
|
24 * @author Gernot Belger |
|
25 */ |
|
26 final class FloodDurationCalculator { |
|
27 |
|
28 private final Collection<ResultRow> rows = new ArrayList<>(); |
|
29 |
|
30 private final RiverInfoProvider riverInfoProvider; |
|
31 |
|
32 public FloodDurationCalculator(final RiverInfoProvider riverInfoProvider) { |
|
33 |
|
34 this.riverInfoProvider = riverInfoProvider; |
|
35 |
|
36 } |
|
37 |
|
38 public FloodDurationCalculationResult execute(final String label, final WstInfo wstInfo, final DoubleRange calcRange) { |
|
39 |
|
40 calculateResultRow(8888.888); |
|
41 calculateResultRow(99); |
|
42 calculateResultRow(77); |
|
43 return new FloodDurationCalculationResult(label, wstInfo, this.rows, 4); |
|
44 } |
|
45 |
|
46 private void calculateResultRow(final double station) { |
|
47 |
|
48 final ResultRow row = ResultRow.create(); |
|
49 |
|
50 // REMARK: access the location once only during calculation |
|
51 final String location = this.riverInfoProvider.getLocation(station); |
|
52 row.putValue(GeneralResultType.station, station); |
|
53 row.putValue(SInfoResultType.riverside, "todo:getRiverside"); |
|
54 row.putValue(SInfoResultType.inundationduration, 44); |
|
55 row.putValue(SInfoResultType.inundationdurationq, 444); |
|
56 row.putValue(SInfoResultType.infrastructureHeight, 55); |
|
57 row.putValue(SInfoResultType.infrastructuretype, "todo_get_infrastructureType"); |
|
58 |
|
59 // custom type; each entry produces 4 Columns |
|
60 final List<DurationWaterlevel> rowWsps = new ArrayList<>(); |
|
61 |
|
62 rowWsps.add(new DurationWaterlevel(222, 30, 666, "1. Test")); |
|
63 rowWsps.add(new DurationWaterlevel(111, 40, 555, "2. Test")); |
|
64 rowWsps.add(new DurationWaterlevel(123, 333, 33, "3. Test")); |
|
65 rowWsps.add(new DurationWaterlevel(444, 452, 55, "4. Test")); |
|
66 row.putValue(SInfoResultType.customMultiRowColWaterlevel, rowWsps); |
|
67 |
|
68 row.putValue(SInfoResultType.gaugeLabel, "todo:getReferencedGauge"); |
|
69 row.putValue(SInfoResultType.location, "location"); |
|
70 |
|
71 this.rows.add(row); |
|
72 } |
|
73 } |