Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java @ 9625:07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
author | mschaefer |
---|---|
date | Mon, 14 Oct 2019 08:14:58 +0200 |
parents | 02ca823ec9c6 |
children |
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 | |
9624
02ca823ec9c6
zu Pos 20 Nachtrag; infrastructureChoice
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9620
diff
changeset
|
12 import java.util.List; |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
13 |
9067 | 14 import org.apache.commons.lang.math.DoubleRange; |
15 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
|
16 import org.dive4elements.river.artifacts.WINFOArtifact; |
9067 | 17 import org.dive4elements.river.artifacts.model.Calculation; |
18 import org.dive4elements.river.artifacts.model.CalculationResult; | |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
19 import org.dive4elements.river.artifacts.model.WQDay; |
9499 | 20 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider; |
9067 | 21 import org.dive4elements.river.artifacts.resources.Resources; |
22 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | |
9624
02ca823ec9c6
zu Pos 20 Nachtrag; infrastructureChoice
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9620
diff
changeset
|
23 import org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureServerClientXChange.Element; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
24 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper; |
9067 | 25 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
|
26 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
9067 | 27 import org.dive4elements.river.model.River; |
28 | |
9176
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 * 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
|
31 * |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
32 * @author Matthias Schäfer |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
33 */ |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9150
diff
changeset
|
34 final class FloodDurationCalculation { |
9067 | 35 |
36 private final CallContext context; | |
37 | |
38 public FloodDurationCalculation(final CallContext context) { | |
39 this.context = context; | |
40 } | |
41 | |
42 public CalculationResult calculate(final SINFOArtifact sinfo) { | |
43 | |
44 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); | |
45 | |
46 /* access input data */ | |
47 final FloodDurationAccess access = new FloodDurationAccess(sinfo); | |
48 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
|
49 final RiverInfo riverInfo = new RiverInfo(river); |
9067 | 50 final DoubleRange calcRange = access.getRange(); |
51 | |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
52 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); |
9067 | 53 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
|
54 final String label = 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); |
9236
b515ed950d39
S-Info flood durations with automatic km step width
mschaefer
parents:
9229
diff
changeset
|
61 winfo.addStringData("ld_mode", "distance"); |
b515ed950d39
S-Info flood durations with automatic km step width
mschaefer
parents:
9229
diff
changeset
|
62 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
|
63 |
9215 | 64 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
|
65 |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
66 calculateResult(label, calcRange, infoProvider, access, problems, winfo, results); |
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 */ |
9612 | 74 private void calculateResult(final String label, final DoubleRange calcRange, final RiverInfoProvider riverInfoProvider, final FloodDurationAccess access, |
75 final Calculation problems, final WINFOArtifact winfo, final FloodDurationCalculationResults results) { | |
9145 | 76 |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
77 final FloodDurationCalculator calculator = new FloodDurationCalculator(this.context, riverInfoProvider); |
9612 | 78 |
9625
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9624
diff
changeset
|
79 final List<Element> infrastructureChoices = access.getInfrastructureChoices(); |
9624
02ca823ec9c6
zu Pos 20 Nachtrag; infrastructureChoice
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9620
diff
changeset
|
80 |
9625
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9624
diff
changeset
|
81 /* |
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9624
diff
changeset
|
82 * zum testen: |
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9624
diff
changeset
|
83 * final Set<String> infrastructureChoicesTest = Infrastructure.fetchInfrastructureTypes(riverInfoProvider.getRiver(), |
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9624
diff
changeset
|
84 * calcRange.getMinimumDouble(), calcRange.getMaximumDouble(), access.getRiverside().getAttributeKey()); |
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9624
diff
changeset
|
85 */ |
9612 | 86 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
87 calculator.execute(problems, label, calcRange, access.getRiverside().getAttributeKey(), infrastructureChoices, access.getIsWspl(), winfo, results); |
9067 | 88 } |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
89 |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
90 /** |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
91 * Calculates the flood duration curve of a station |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
92 */ |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
93 public WQDay calcStationCurve(final double station, final SINFOArtifact sinfo) { |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
94 |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
95 /* access input data */ |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
96 final FloodDurationAccess access = new FloodDurationAccess(sinfo); |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
97 final River river = access.getRiver(); |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
98 final DoubleRange calcRange = access.getRange(); |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
99 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
100 |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
101 final Calculation problems = new Calculation(); |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
102 |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
103 // Calculate the selected main values, if any |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
104 /* misuse winfo-artifact to calculate waterlevels in the same way */ |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
105 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
106 |
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
107 final FloodDurationCalculator calculator = new FloodDurationCalculator(this.context, infoProvider); |
9534
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
108 if (!Double.isNaN(station)) { |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
109 winfo.addStringData("ld_locations", Double.toString(station)); |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
110 return calculator.calcWQDays(problems, station, winfo); |
9612 | 111 } else { |
9534
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
112 winfo.addStringData("ld_locations", Double.toString(calcRange.getMinimumDouble())); |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
113 return calculator.calcWQDays(problems, calcRange.getMinimumDouble(), winfo); |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
114 } |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9252
diff
changeset
|
115 } |
9067 | 116 } |