annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java @ 8997:d5802f22e4f5

Work on uinfo
author gernotbelger
date Thu, 12 Apr 2018 19:14:19 +0200
parents 0adc6d04de95
children 740d65e4aa14
rev   line source
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
2 * Software engineering by
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
5 *
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
9 */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
10 package org.dive4elements.river.artifacts.sinfo.flowdepthminmax;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
11
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
12 import java.util.ArrayList;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
13 import java.util.Collection;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
14
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
15 import org.apache.commons.lang.math.DoubleRange;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
16 import org.dive4elements.artifacts.CallContext;
8997
d5802f22e4f5 Work on uinfo
gernotbelger
parents: 8993
diff changeset
17 import org.dive4elements.river.artifacts.common.GeneralResultType;
d5802f22e4f5 Work on uinfo
gernotbelger
parents: 8993
diff changeset
18 import org.dive4elements.river.artifacts.common.ResultRow;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
19 import org.dive4elements.river.artifacts.model.Calculation;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
20 import org.dive4elements.river.artifacts.model.CalculationResult;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
21 import org.dive4elements.river.artifacts.model.WKms;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
22 import org.dive4elements.river.artifacts.resources.Resources;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
23 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
24 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider;
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
25 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
26 import org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthUtils;
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
27 import org.dive4elements.river.artifacts.sinfo.flowdepth.WstSoundingIdPair;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
28 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
29 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.WaterlevelValuesFinder;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
30 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
31 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
32 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
33 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
34 import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
35 import org.dive4elements.river.artifacts.states.WaterlevelData;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
36 import org.dive4elements.river.artifacts.states.WaterlevelFetcher;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
37 import org.dive4elements.river.model.River;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
38
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
39 /**
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
40 * @author Gernot Belger
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
41 */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
42 final class FlowDepthMinMaxCalculation {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
43
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
44 private final CallContext context;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
45
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
46 public FlowDepthMinMaxCalculation(final CallContext context) {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
47 this.context = context;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
48 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
49
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
50 public CalculationResult calculate(final SINFOArtifact sinfo) {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
51
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
52 final String user = CalculationUtils.findArtifactUser(this.context, sinfo);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
53
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
54 /* access input data */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
55 final FlowDepthMinMaxAccess access = new FlowDepthMinMaxAccess(sinfo);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
56 final River river = access.getRiver();
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
57 final RiverInfo riverInfo = new RiverInfo(river);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
58
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
59 final Collection<WstSoundingIdPair> minMaxPairs = access.getMinMaxPairs();
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
60
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
61 final DoubleRange calcRange = access.getRange();
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
62
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
63 /* calculate results for each diff pair */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
64 final Calculation problems = new Calculation();
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
65
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
66 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
67
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
68 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name());
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
69
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
70 final FlowDepthMinMaxCalculationResults results = new FlowDepthMinMaxCalculationResults(calcModeLabel, user, riverInfo, calcRange);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
71
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
72 for (final WstSoundingIdPair minMaxPair : minMaxPairs) {
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
73 final FlowDepthMinMaxCalculationResult result = calculateResult(calcRange, minMaxPair, problems, infoProvider);
8980
b194fa64506a SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents: 8978
diff changeset
74 results.addResult(result, problems);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
75 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
76
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
77 return new CalculationResult(results, problems);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
78 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
79
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
80 /**
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
81 * Calculates one W-MSH differences pair.
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
82 *
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
83 * @param infoProvider
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
84 */
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
85 private FlowDepthMinMaxCalculationResult calculateResult(final DoubleRange calcRange, final WstSoundingIdPair minMaxPair, final Calculation problems,
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
86 final RiverInfoProvider infoProvider) {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
87
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
88 /* access real input data from database */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
89 final String wstId = minMaxPair.getWstId();
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
90
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
91 final String soundingId = minMaxPair.getSoundingId();
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
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
93 final BedHeightsFinder bedHeight = BedHeightsFinder.forId(this.context, soundingId, calcRange, problems);
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
94 if (bedHeight == null)
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
95 return null;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
96
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
97 /* 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
98 final WaterlevelData waterlevel = new WaterlevelFetcher().findWaterlevel(this.context, wstId, calcRange, problems);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
99 if (waterlevel == null)
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
100 return null;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
101
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
102 final String label = createLabel(waterlevel, bedHeight);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
103
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
104 final WKms wstKms = waterlevel.getWkms();
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
105
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
106 final BedHeightInfo bedHeightInfo = bedHeight.getInfo();
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
107
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
108 final int soundingYear = bedHeightInfo.getYear();
8951
322b0e6298ea Work on SINFO FlowDepth-Development
gernotbelger
parents: 8948
diff changeset
109 FlowDepthUtils.checkYearDifference(label, waterlevel.getYear(), soundingYear, problems);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
110
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
111 /* re-determine the reference gauge, in the same way as the WaterlevelArtifact would do it */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
112 final RiverInfoProvider riverInfoProvider = infoProvider.forWaterlevel(waterlevel);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
113
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
114 final int wspYear = waterlevel.getYear();
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
115 final WstInfo wstInfo = new WstInfo(waterlevel.getName(), wspYear, riverInfoProvider.getReferenceGauge());
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
116
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
117 final WaterlevelValuesFinder waterlevelProvider = WaterlevelValuesFinder.fromKms(problems, wstKms);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
118 final DischargeValuesFinder dischargeProvider = DischargeValuesFinder.fromKms(wstKms);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
119
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
120 final String waterlevelLabel = waterlevel.getName();
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
121 final String soundingLabel = bedHeightInfo.getDescription();
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
122
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
123 /* real calculation loop */
8997
d5802f22e4f5 Work on uinfo
gernotbelger
parents: 8993
diff changeset
124 final Collection< ResultRow> rows = new ArrayList<>();
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
125
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
126 final Collection<Double> stations = bedHeight.getStations();
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
127 for (final double station : stations) {
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
128 if (calcRange.containsDouble(station)) {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
129
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
130 final double wst = waterlevelProvider.getWaterlevel(station);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
131 final double discharge = dischargeProvider.getDischarge(station);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
132
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
133 final double minBedHeightValue = bedHeight.getMinBedHeight(station);
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
134 final double maxBedHeightValue = bedHeight.getMaxBedHeight(station);
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
135 final double meanBedHeight = bedHeight.getMeanBedHeight(station);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
136
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
137 final double minFlowDepth = wst - maxBedHeightValue;
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
138 final double maxFlowDepth = wst - minBedHeightValue;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
139
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
140 // REMARK: access the location once only during calculation
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
141 final String location = riverInfoProvider.getLocation(station);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
142
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
143 // REMARK: access the gauge once only during calculation
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
144 final String gaugeLabel = riverInfoProvider.findGauge(station);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
145
8978
b5600453bb8f SINFO Calculations: do not produce result rows if some input data has missing values.
gernotbelger
parents: 8964
diff changeset
146 /* ignore invalid lines */
b5600453bb8f SINFO Calculations: do not produce result rows if some input data has missing values.
gernotbelger
parents: 8964
diff changeset
147 if (Double.isNaN(wst) || Double.isNaN(minBedHeightValue) || Double.isNaN(maxBedHeightValue))
b5600453bb8f SINFO Calculations: do not produce result rows if some input data has missing values.
gernotbelger
parents: 8964
diff changeset
148 continue;
b5600453bb8f SINFO Calculations: do not produce result rows if some input data has missing values.
gernotbelger
parents: 8964
diff changeset
149
8997
d5802f22e4f5 Work on uinfo
gernotbelger
parents: 8993
diff changeset
150 final ResultRow row = ResultRow.create().//
d5802f22e4f5 Work on uinfo
gernotbelger
parents: 8993
diff changeset
151 putValue(GeneralResultType.station, station). //
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
152 putValue(SInfoResultType.flowdepthmin, minFlowDepth). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
153 putValue(SInfoResultType.flowdepthmax, maxFlowDepth). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
154 putValue(SInfoResultType.waterlevel, wst). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
155 putValue(SInfoResultType.discharge, discharge). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
156 putValue(SInfoResultType.waterlevelLabel, waterlevelLabel). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
157 putValue(SInfoResultType.gaugeLabel, gaugeLabel). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
158 putValue(SInfoResultType.meanBedHeight, meanBedHeight). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
159 putValue(SInfoResultType.soundingLabel, soundingLabel). //
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
160 putValue(SInfoResultType.location, location);
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
161 rows.add(row);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
162 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
163 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
164
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
165 return new FlowDepthMinMaxCalculationResult(label, wstInfo, bedHeightInfo, rows);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
166 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
167
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
168 private String createLabel(final WaterlevelData waterlevel, final BedHeightsFinder bedHeight) {
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
169
8993
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
170 return new StringBuilder(waterlevel.getName()). //
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
171 append(" - "). //
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
172 append(bedHeight.getInfo().getDescription()). //
0adc6d04de95 SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
gernotbelger
parents: 8980
diff changeset
173 toString();
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
174 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
175 }

http://dive4elements.wald.intevation.org