Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java @ 9195:a4121ec450d6
'ca.'-issue
ExportContextCSV+PDF separated
uinfo.inundationduration url export
author | gernotbelger |
---|---|
date | Fri, 29 Jun 2018 14:52:54 +0200 |
parents | 1614cb14308f |
children | b4402594213b |
comparison
equal
deleted
inserted
replaced
9191:f692f5a0536a | 9195:a4121ec450d6 |
---|---|
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.sinfo.flood_duration; | 10 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
11 | 11 |
12 import org.apache.commons.lang.math.DoubleRange; | 12 import org.apache.commons.lang.math.DoubleRange; |
13 import org.dive4elements.artifacts.CallContext; | 13 import org.dive4elements.artifacts.CallContext; |
14 import org.dive4elements.river.artifacts.WINFOArtifact; | |
15 import org.dive4elements.river.artifacts.model.Calculation; | 14 import org.dive4elements.river.artifacts.model.Calculation; |
16 import org.dive4elements.river.artifacts.model.CalculationResult; | 15 import org.dive4elements.river.artifacts.model.CalculationResult; |
17 import org.dive4elements.river.artifacts.resources.Resources; | 16 import org.dive4elements.river.artifacts.resources.Resources; |
18 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | 17 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
19 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; | 18 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; |
20 import org.dive4elements.river.artifacts.sinfo.flood_duration.RiversideRadioChoice.RiversideChoiceKey; | 19 import org.dive4elements.river.artifacts.sinfo.flood_duration.RiversideRadioChoice.RiversideChoiceKey; |
21 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper; | |
22 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; | 20 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; |
23 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
24 import org.dive4elements.river.model.River; | 21 import org.dive4elements.river.model.River; |
25 import org.dive4elements.river.model.sinfo.Infrastructure; | 22 import org.dive4elements.river.model.sinfo.Infrastructure; |
26 | 23 |
27 /** | 24 /** |
28 * Calculation of the flood durations of the infrastructures of the km range of a river | 25 * Calculation of the flood durations of the infrastructures of the km range of a river |
42 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); | 39 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); |
43 | 40 |
44 /* access input data */ | 41 /* access input data */ |
45 final FloodDurationAccess access = new FloodDurationAccess(sinfo); | 42 final FloodDurationAccess access = new FloodDurationAccess(sinfo); |
46 final River river = access.getRiver(); | 43 final River river = access.getRiver(); |
47 final RiverInfo riverInfo = new RiverInfo(river); | |
48 final DoubleRange calcRange = access.getRange(); | 44 final DoubleRange calcRange = access.getRange(); |
49 | 45 |
50 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); | 46 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); |
51 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); | 47 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); |
52 final String riverside = Resources.getMsg(this.context.getMeta(), access.getRiverside()); | 48 final String riverside = Resources.getMsg(this.context.getMeta(), access.getRiverside()); |
53 final Infrastructure infrasSeries = Infrastructure.getSeries(river); | 49 final Infrastructure infrasSeries = Infrastructure.getSeries(river); |
54 final String infrasType = (infrasSeries != null) ? infrasSeries.getType().getName() : "?"; | 50 final String infrasType = (infrasSeries != null) ? infrasSeries.getType().getName() : "?"; |
55 | 51 |
56 final Calculation problems = new Calculation(); | 52 final Calculation problems = new Calculation(); |
57 | 53 |
58 final FloodDurationCalculationResults results = new FloodDurationCalculationResults(calcModeLabel, user, riverInfo, calcRange); | 54 final FloodDurationCalculationResults results = calculateResult(calcModeLabel, infrasType, riverside, calcRange, infoProvider, |
59 | |
60 final FloodDurationCalculationResult result = calculateResult(calcModeLabel, infrasType, riverside, calcRange, infoProvider, | |
61 RiversideChoiceKey.fromKey(access.getRiverside()), user, problems); | 55 RiversideChoiceKey.fromKey(access.getRiverside()), user, problems); |
62 results.addResult(result, problems); | |
63 | |
64 // Calculate the selected main values, if any | |
65 /* misuse winfo-artifact to calculate waterlevels in the same way */ | |
66 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); | |
67 | 56 |
68 return new CalculationResult(results, problems); | 57 return new CalculationResult(results, problems); |
69 } | 58 } |
70 | 59 |
71 /** | 60 /** |
72 * Calculates the flood durations of the infrastructures of a km range of a river | 61 * Calculates the flood durations of the infrastructures of a km range of a river |
73 */ | 62 */ |
74 private FloodDurationCalculationResult calculateResult(final String calcModeLabel, final String infrastructureType, final String riverside, | 63 private FloodDurationCalculationResults calculateResult(final String calcModeLabel, final String infrastructureType, final String riverside, |
75 final DoubleRange calcRange, final RiverInfoProvider riverInfoProvider, final RiversideChoiceKey riversideKey, final String user, | 64 final DoubleRange calcRange, final RiverInfoProvider riverInfoProvider, final RiversideChoiceKey riversideKey, final String user, |
76 final Calculation problems) { | 65 final Calculation problems) { |
77 | 66 |
78 final FloodDurationCalculator calculator = new FloodDurationCalculator(this.context, riverInfoProvider); | 67 final FloodDurationCalculator calculator = new FloodDurationCalculator(this.context, riverInfoProvider); |
79 final String label = infrastructureType + ", " + riverside; | 68 final String label = infrastructureType + ", " + riverside; |
80 return calculator.execute(problems, label, calcModeLabel, calcRange, riversideKey, user).getResult(); | 69 return calculator.execute(problems, label, calcModeLabel, calcRange, riversideKey, user); |
81 } | 70 } |
82 } | 71 } |