Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java @ 9215:0fc9c82e744e
work on collison, flood_duration
author | gernotbelger |
---|---|
date | Tue, 03 Jul 2018 17:00:48 +0200 |
parents | 3dae6b78e1da |
children | 0dcd1cd41915 |
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 String riverside = Resources.getMsg(this.context.getMeta(), access.getRiverside()); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
53 final Infrastructure infrasSeries = Infrastructure.getSeries(river); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
54 final String infrasType = (infrasSeries != null) ? infrasSeries.getType().getName() : "?"; |
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); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
61 |
9215 | 62 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
|
63 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
64 final FloodDurationCalculationResult result = calculateResult(infrasType, riverside, calcRange, infoProvider, |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
65 RiversideChoiceKey.fromKey(access.getRiverside()), problems, winfo); |
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 */ |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
74 private FloodDurationCalculationResult calculateResult(final String infrastructureType, final String riverside, final DoubleRange calcRange, |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
75 final RiverInfoProvider riverInfoProvider, final RiversideChoiceKey riversideKey, 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); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
78 final String label = infrastructureType + ", " + riverside; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
79 return calculator.execute(problems, label, calcRange, riversideKey, winfo); |
9067 | 80 } |
81 } |