Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java @ 9581:b61e2a9fa5d6
Punkt 4.1. Mittlere Sohlhöhe (lang, statt "Sohl-")
author | gernotbelger |
---|---|
date | Tue, 08 Jan 2019 17:34:53 +0100 |
parents | 853f2dafc16e |
children |
rev | line source |
---|---|
8854 | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
8877 | 2 * Software engineering by |
3 * Björnsen Beratende Ingenieure GmbH | |
8854 | 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.flowdepth; | |
11 | |
12 import java.util.Collection; | |
13 | |
8894 | 14 import org.apache.commons.lang.math.DoubleRange; |
8854 | 15 import org.dive4elements.artifacts.CallContext; |
16 import org.dive4elements.river.artifacts.model.Calculation; | |
17 import org.dive4elements.river.artifacts.model.CalculationResult; | |
18 import org.dive4elements.river.artifacts.model.WKms; | |
9499 | 19 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider; |
8854 | 20 import org.dive4elements.river.artifacts.resources.Resources; |
21 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
22 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder; |
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
23 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator; |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
24 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.WaterlevelValuesFinder; |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
25 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; |
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
26 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; |
8894 | 27 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
28 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
8882 | 29 import org.dive4elements.river.artifacts.states.WaterlevelData; |
30 import org.dive4elements.river.artifacts.states.WaterlevelFetcher; | |
8854 | 31 import org.dive4elements.river.model.River; |
32 | |
33 class FlowDepthCalculation { | |
34 | |
9067 | 35 // private static Logger log = Logger.getLogger(FloodDurationCalculation.class); |
8898 | 36 |
8877 | 37 private final CallContext context; |
8854 | 38 |
8882 | 39 public FlowDepthCalculation(final CallContext context) { |
8877 | 40 this.context = context; |
8854 | 41 } |
42 | |
8877 | 43 public CalculationResult calculate(final SINFOArtifact sinfo) { |
8854 | 44 |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
45 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); |
8854 | 46 |
8877 | 47 /* access input data */ |
48 final FlowDepthAccess access = new FlowDepthAccess(sinfo); | |
49 final River river = access.getRiver(); | |
8894 | 50 final RiverInfo riverInfo = new RiverInfo(river); |
8854 | 51 |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
52 final Collection<WstSoundingIdPair> diffPairs = access.getDifferencePairs(); |
8877 | 53 |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
54 final DoubleRange calcRange = access.getRange(); |
8877 | 55 |
56 final boolean useTkh = access.isUseTransportBodies(); | |
57 | |
58 /* calculate results for each diff pair */ | |
59 final Calculation problems = new Calculation(); | |
60 | |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
61 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); |
8877 | 62 |
8882 | 63 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); |
8877 | 64 |
8894 | 65 final FlowDepthCalculationResults results = new FlowDepthCalculationResults(calcModeLabel, user, riverInfo, calcRange, useTkh); |
8877 | 66 |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
67 for (final WstSoundingIdPair diffPair : diffPairs) { |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
68 final FlowDepthCalculationResult result = calculateResult(calcRange, diffPair, problems, infoProvider, useTkh); |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8964
diff
changeset
|
69 results.addResult(result, problems); |
8877 | 70 } |
71 | |
8882 | 72 return new CalculationResult(results, problems); |
8877 | 73 } |
74 | |
8898 | 75 /** |
76 * Calculates one W-MSH differences pair. | |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
77 * |
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
78 * @param infoProvider |
8898 | 79 */ |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
80 private FlowDepthCalculationResult calculateResult(final DoubleRange calcRange, final WstSoundingIdPair diffPair, final Calculation problems, |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
81 final RiverInfoProvider infoProvider, final boolean useTkh) { |
8877 | 82 |
83 /* access real input data from database */ | |
84 final String soundingId = diffPair.getSoundingId(); | |
85 final String wstId = diffPair.getWstId(); | |
86 | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
87 final BedHeightsFinder bedHeight = BedHeightsFinder.forId(this.context, soundingId, calcRange, problems); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
88 if (bedHeight == null) |
8877 | 89 return null; |
90 | |
8882 | 91 /* REMARK: fetch ALL wst kms, because we want to determine the original reference gauge */ |
8964
45f1ad66560e
Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents:
8951
diff
changeset
|
92 final WaterlevelData waterlevel = new WaterlevelFetcher().findWaterlevel(this.context, wstId, calcRange, problems); |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
93 if (waterlevel == null) |
8877 | 94 return null; |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8915
diff
changeset
|
95 |
8882 | 96 final WKms wstKms = waterlevel.getWkms(); |
97 | |
8883 | 98 final String wspLabel = wstKms.getName(); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9170
diff
changeset
|
99 |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
100 final String soundingLabel = bedHeight.getInfo().getDescription(); |
8883 | 101 final String label = String.format("%s - %s", wspLabel, soundingLabel); |
8877 | 102 |
8951 | 103 FlowDepthUtils.checkYearDifference(label, waterlevel.getYear(), bedHeight.getInfo().getYear(), problems); |
8882 | 104 |
105 /* re-determine the reference gauge, in the same way as the WaterlevelArtifact would do it */ | |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
106 final RiverInfoProvider riverInfoProvider = infoProvider.forWaterlevel(waterlevel); |
8894 | 107 |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
108 final int wspYear = waterlevel.getYear(); |
9362
392745cccede
Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents:
9205
diff
changeset
|
109 final WstInfo wstInfo = new WstInfo(wspLabel, wspYear, riverInfoProvider.getReferenceGauge(), waterlevel.isShowRefGauges()); |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8911
diff
changeset
|
110 |
8964
45f1ad66560e
Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents:
8951
diff
changeset
|
111 final WaterlevelValuesFinder waterlevelProvider = WaterlevelValuesFinder.fromKms(problems, wstKms); |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
112 final DischargeValuesFinder dischargeProvider = DischargeValuesFinder.fromKms(wstKms); |
8886 | 113 |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
114 final River river = riverInfoProvider.getRiver(); |
9170 | 115 final TkhCalculator tkhCalculator = TkhCalculator.buildTkhCalculator(useTkh, problems, label, river, calcRange, waterlevelProvider, dischargeProvider, |
116 bedHeight); | |
8883 | 117 |
9365
ba1e2e8f05d1
sinfo.flowdepth Results.isShowRefGauge==false->spalte ausblenden; result.isShowRefGauge==false&&results.isShowRefGauge==true->result.refGauge=""
gernotbelger
parents:
9362
diff
changeset
|
118 final FlowDepthCalculator calculator = new FlowDepthCalculator(riverInfoProvider, wspLabel, bedHeight, tkhCalculator, wstInfo.isShowRefGauges()); |
8915
d9dbf0b74bc2
Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
8914
diff
changeset
|
119 return calculator.execute(label, wstInfo, calcRange); |
8877 | 120 } |
8884 | 121 } |