Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java @ 9236:b515ed950d39
S-Info flood durations with automatic km step width
author | mschaefer |
---|---|
date | Fri, 06 Jul 2018 17:56:18 +0200 |
parents | 0dcd1cd41915 |
children | c2a0028bfa9f |
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; |
25 | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
26 /** |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
27 * 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
|
28 * |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
29 * @author Matthias Schäfer |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
30 */ |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
31 final class FloodDurationCalculation { |
9067 | 32 |
33 private final CallContext context; | |
34 | |
35 public FloodDurationCalculation(final CallContext context) { | |
36 this.context = context; | |
37 } | |
38 | |
39 public CalculationResult calculate(final SINFOArtifact sinfo) { | |
40 | |
41 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); | |
42 | |
43 /* access input data */ | |
44 final FloodDurationAccess access = new FloodDurationAccess(sinfo); | |
45 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
|
46 final RiverInfo riverInfo = new RiverInfo(river); |
9067 | 47 final DoubleRange calcRange = access.getRange(); |
48 | |
49 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); | |
50 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); | |
9236
b515ed950d39
S-Info flood durations with automatic km step width
mschaefer
parents:
9229
diff
changeset
|
51 final String label = Resources.getMsg(this.context.getMeta(), access.getRiverside().getKey()); |
9067 | 52 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
53 final Calculation problems = new Calculation(); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
54 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
55 // 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
|
56 /* 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
|
57 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); |
9236
b515ed950d39
S-Info flood durations with automatic km step width
mschaefer
parents:
9229
diff
changeset
|
58 winfo.addStringData("ld_mode", "distance"); |
b515ed950d39
S-Info flood durations with automatic km step width
mschaefer
parents:
9229
diff
changeset
|
59 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
|
60 |
9215 | 61 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
|
62 |
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
|
63 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
|
64 results.addResult(result, problems); |
9067 | 65 |
9145 | 66 return new CalculationResult(results, problems); |
67 } | |
68 | |
69 /** | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
70 * Calculates the flood durations of the infrastructures of a km range of a river |
9145 | 71 */ |
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
|
72 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
|
73 final RiversideChoiceKey riverside, final Calculation problems, final WINFOArtifact winfo) { |
9145 | 74 |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
75 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
|
76 return calculator.execute(problems, label, calcRange, riverside, winfo); |
9067 | 77 } |
78 } |