comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java @ 8948:a4f1ac81f26d

Work on SINFO-FlowDepthMinMax. Also rework of result row stuff, in order to reduce abstraction, using result type concept
author gernotbelger
date Wed, 14 Mar 2018 14:10:32 +0100
parents 5d5d482da3e9
children 322b0e6298ea
comparison
equal deleted inserted replaced
8947:86650594f051 8948:a4f1ac81f26d
18 import org.dive4elements.river.artifacts.model.CalculationResult; 18 import org.dive4elements.river.artifacts.model.CalculationResult;
19 import org.dive4elements.river.artifacts.model.WKms; 19 import org.dive4elements.river.artifacts.model.WKms;
20 import org.dive4elements.river.artifacts.resources.Resources; 20 import org.dive4elements.river.artifacts.resources.Resources;
21 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; 21 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
22 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; 22 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider;
23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultRow;
24 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
23 import org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthUtils; 25 import org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthUtils;
24 import org.dive4elements.river.artifacts.sinfo.flowdepthminmax.FlowDepthMinMaxAccess.MinMaxIdPair; 26 import org.dive4elements.river.artifacts.sinfo.flowdepthminmax.FlowDepthMinMaxAccess.MinMaxIdPair;
25 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder; 27 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder;
26 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.WaterlevelValuesFinder; 28 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.WaterlevelValuesFinder;
27 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; 29 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder;
84 final RiverInfoProvider infoProvider) { 86 final RiverInfoProvider infoProvider) {
85 87
86 /* access real input data from database */ 88 /* access real input data from database */
87 final String wstId = minMaxPair.getWstId(); 89 final String wstId = minMaxPair.getWstId();
88 final String minSoundingId = minMaxPair.getMinSoundingId(); 90 final String minSoundingId = minMaxPair.getMinSoundingId();
89 final String maxSoundingId = minMaxPair.getMinSoundingId(); 91 final String maxSoundingId = minMaxPair.getMaxSoundingId();
90 92
91 final BedHeightsFinder minBedHeight = minSoundingId == null ? null : BedHeightsFinder.forId(this.context, minSoundingId, calcRange, problems); 93 final BedHeightsFinder minBedHeight = minSoundingId == null ? null : BedHeightsFinder.forId(this.context, minSoundingId, calcRange, problems);
92 final BedHeightsFinder maxBedHeight = maxSoundingId == null ? null : BedHeightsFinder.forId(this.context, maxSoundingId, calcRange, problems); 94 final BedHeightsFinder maxBedHeight = maxSoundingId == null ? null : BedHeightsFinder.forId(this.context, maxSoundingId, calcRange, problems);
93 if (minBedHeight == null && maxBedHeight == null) 95 if (minBedHeight == null && maxBedHeight == null)
94 return null; 96 return null;
119 121
120 final String waterlevelLabel = waterlevel.getName(); 122 final String waterlevelLabel = waterlevel.getName();
121 final String soundingLabel = buildSoundingLabel(minBedHeight, maxBedHeight); 123 final String soundingLabel = buildSoundingLabel(minBedHeight, maxBedHeight);
122 124
123 /* real calculation loop */ 125 /* real calculation loop */
124 final Collection<FlowDepthMinMaxRow> rows = new ArrayList<>(); 126 final Collection<SInfoResultRow> rows = new ArrayList<>();
125 127
126 // FIXME: determine what is the spatial discretisation that we will use... 128 // FIXME: determine what is the spatial discretisation that we will use...
127 final double[] allKms = wstKms.allKms().toNativeArray(); 129 final double[] allKms = wstKms.allKms().toNativeArray();
128 for (final double station : allKms) { 130 for (final double station : allKms) {
129 if (calcRange.containsDouble(station)) { 131 if (calcRange.containsDouble(station)) {
144 final String location = riverInfoProvider.getLocation(station); 146 final String location = riverInfoProvider.getLocation(station);
145 147
146 // REMARK: access the gauge once only during calculation 148 // REMARK: access the gauge once only during calculation
147 final String gaugeLabel = riverInfoProvider.findGauge(station); 149 final String gaugeLabel = riverInfoProvider.findGauge(station);
148 150
149 rows.add(new FlowDepthMinMaxRow(station, minFlowDepth, maxFlowDepth, wst, discharge, waterlevelLabel, gaugeLabel, meanBedHeight, soundingLabel, 151 final SInfoResultRow row = SInfoResultRow.create().//
150 location)); 152 putValue(SInfoResultType.station, station). //
153 putValue(SInfoResultType.flowdepthmin, minFlowDepth). //
154 putValue(SInfoResultType.flowdepthmax, maxFlowDepth). //
155 putValue(SInfoResultType.waterlevel, wst). //
156 putValue(SInfoResultType.discharge, discharge). //
157 putValue(SInfoResultType.waterlevelLabel, waterlevelLabel). //
158 putValue(SInfoResultType.gaugeLabel, gaugeLabel). //
159 putValue(SInfoResultType.meanBedHeight, meanBedHeight). //
160 putValue(SInfoResultType.soundingLabel, soundingLabel). //
161 putValue(SInfoResultType.location, location);
162 rows.add(row);
151 } 163 }
152 } 164 }
153 165
154 final BedHeightInfo minBedHeightInfo = minBedHeight == null ? null : minBedHeight.getInfo(); 166 final BedHeightInfo minBedHeightInfo = minBedHeight == null ? null : minBedHeight.getInfo();
155 final BedHeightInfo maxBedHeightInfo = maxBedHeight == null ? null : maxBedHeight.getInfo(); 167 final BedHeightInfo maxBedHeightInfo = maxBedHeight == null ? null : maxBedHeight.getInfo();
168
156 return new FlowDepthMinMaxCalculationResult(label, wstInfo, minBedHeightInfo, maxBedHeightInfo, rows); 169 return new FlowDepthMinMaxCalculationResult(label, wstInfo, minBedHeightInfo, maxBedHeightInfo, rows);
157 } 170 }
158 171
159 private String buildSoundingLabel(final BedHeightsFinder minBedHeight, final BedHeightsFinder maxBedHeight) { 172 private String buildSoundingLabel(final BedHeightsFinder minBedHeight, final BedHeightsFinder maxBedHeight) {
160 173

http://dive4elements.wald.intevation.org