Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java @ 9229:0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
author | mschaefer |
---|---|
date | Thu, 05 Jul 2018 16:49:42 +0200 |
parents | 0fc9c82e744e |
children | b515ed950d39 |
rev | line source |
---|---|
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9067 | 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 org.apache.commons.lang.math.DoubleRange; | |
13 import org.dive4elements.artifacts.CallContext; | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
14 import org.dive4elements.river.artifacts.WINFOArtifact; |
9067 | 15 import org.dive4elements.river.artifacts.model.Calculation; |
16 import org.dive4elements.river.artifacts.model.CalculationResult; | |
17 import org.dive4elements.river.artifacts.resources.Resources; | |
18 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | |
19 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
20 import org.dive4elements.river.artifacts.sinfo.flood_duration.RiversideRadioChoice.RiversideChoiceKey; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
21 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper; |
9067 | 22 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
23 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
9067 | 24 import org.dive4elements.river.model.River; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
25 import org.dive4elements.river.model.sinfo.Infrastructure; |
9067 | 26 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
27 /** |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
28 * Calculation of the flood durations of the infrastructures of the km range of a river |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
29 * |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
30 * @author Matthias Schäfer |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
31 */ |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
32 final class FloodDurationCalculation { |
9067 | 33 |
34 private final CallContext context; | |
35 | |
36 public FloodDurationCalculation(final CallContext context) { | |
37 this.context = context; | |
38 } | |
39 | |
40 public CalculationResult calculate(final SINFOArtifact sinfo) { | |
41 | |
42 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); | |
43 | |
44 /* access input data */ | |
45 final FloodDurationAccess access = new FloodDurationAccess(sinfo); | |
46 final River river = access.getRiver(); | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
47 final RiverInfo riverInfo = new RiverInfo(river); |
9067 | 48 final DoubleRange calcRange = access.getRange(); |
49 | |
50 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); | |
51 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
52 final Infrastructure infrasSeries = Infrastructure.getSeries(river); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
53 final String infrasType = (infrasSeries != null) ? infrasSeries.getType().getName() : "?"; |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
54 final String label = infrasType + ", " + Resources.getMsg(this.context.getMeta(), access.getRiverside().getKey()); |
9067 | 55 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
56 final Calculation problems = new Calculation(); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
57 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
58 // Calculate the selected main values, if any |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
59 /* misuse winfo-artifact to calculate waterlevels in the same way */ |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
60 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
61 // TODO Aktivieren wenn Step-Eingabe im Workflow weg: winfo.addStringData("ld_step", "100"); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
62 |
9215 | 63 final FloodDurationCalculationResults results = new FloodDurationCalculationResults(calcModeLabel, user, riverInfo, calcRange); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
64 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
65 final FloodDurationCalculationResult result = calculateResult(label, calcRange, infoProvider, access.getRiverside(), problems, winfo); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
66 results.addResult(result, problems); |
9067 | 67 |
9145 | 68 return new CalculationResult(results, problems); |
69 } | |
70 | |
71 /** | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
72 * Calculates the flood durations of the infrastructures of a km range of a river |
9145 | 73 */ |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
74 private FloodDurationCalculationResult calculateResult(final String label, final DoubleRange calcRange, final RiverInfoProvider riverInfoProvider, |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
75 final RiversideChoiceKey riverside, final Calculation problems, final WINFOArtifact winfo) { |
9145 | 76 |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
77 final FloodDurationCalculator calculator = new FloodDurationCalculator(this.context, riverInfoProvider); |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
78 return calculator.execute(problems, label, calcRange, riverside, winfo); |
9067 | 79 } |
80 } |