comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java @ 8886:cc86b0f9b3c3

SINFO-FlowDepth - work on tkh themes
author gernotbelger
date Wed, 14 Feb 2018 18:10:53 +0100
parents 7a8c12706834
children f431aec10d2c
comparison
equal deleted inserted replaced
8885:e5f688820951 8886:cc86b0f9b3c3
153 final List<BedHeightValue> values = bedHeight.getValues(); 153 final List<BedHeightValue> values = bedHeight.getValues();
154 154
155 final List<BedHeightValue> sortedValues = new ArrayList<>(values); 155 final List<BedHeightValue> sortedValues = new ArrayList<>(values);
156 Collections.sort(sortedValues, new BedHeightStationComparator()); 156 Collections.sort(sortedValues, new BedHeightStationComparator());
157 157
158 SoilKind lastKind = SoilKind.mobil;
159
158 for (final BedHeightValue bedHeightValue : sortedValues) { 160 for (final BedHeightValue bedHeightValue : sortedValues) {
159 161
160 final Double station = bedHeightValue.getStation(); 162 final Double station = bedHeightValue.getStation();
161 if (station == null || station.isNaN()) 163 if (station == null || station.isNaN())
162 continue; 164 continue;
177 // FIXME: piecewise constant interpolation? 179 // FIXME: piecewise constant interpolation?
178 // final double discharge = wstKms instanceof QKms ? ((QKms) wstKms).getQ(i) : Double.NaN; 180 // final double discharge = wstKms instanceof QKms ? ((QKms) wstKms).getQ(i) : Double.NaN;
179 final double discharge = Double.NaN; 181 final double discharge = Double.NaN;
180 182
181 // FIXME: calculate tkh 183 // FIXME: calculate tkh
182 final double tkh = 0; 184
183 final double flowDepthTkh = flowDepth - tkh; 185 // REMARK: bissl spielerei zum testen damit die sohlart nicht zu schnell wechselt
186 final boolean changeKind = Math.random() > 0.95;
187 SoilKind kind;
188 if (changeKind) {
189 switch (lastKind) {
190 case starr:
191 kind = SoilKind.mobil;
192 break;
193
194 case mobil:
195 default:
196 kind = SoilKind.starr;
197 break;
198
199 }
200 } else
201 kind = lastKind;
202 lastKind = kind;
203
204 final double tkh = 100 + 10 * (Math.random() - 0.5);
205
206 final double flowDepthTkh;
207 final double tkhUp;
208 final double tkhDown;
209 switch (kind) {
210 case starr:
211 flowDepthTkh = wst - (meanBedHeight + tkh / 100);
212 tkhUp = tkh;
213 tkhDown = 0;
214 break;
215
216 case mobil:
217 default:
218 flowDepthTkh = wst - (meanBedHeight + tkh / 200);
219 tkhUp = tkh / 2;
220 tkhDown = -tkh / 2;
221 break;
222 }
223
184 224
185 // REMARK: access the location once only during calculation 225 // REMARK: access the location once only during calculation
186 final String location = LocationProvider.getLocation(river.getName(), km); 226 final String location = LocationProvider.getLocation(river.getName(), km);
187 227
188 // REMARK: access the gauge once only during calculation 228 // REMARK: access the gauge once only during calculation
189 final Gauge gauge = findGauge(waterlevel, refGauge, gaugeIndex, km); 229 final Gauge gauge = findGauge(waterlevel, refGauge, gaugeIndex, km);
190 230
191 final String gaugeLabel = gauge == null ? notinrange : gauge.getName(); 231 final String gaugeLabel = gauge == null ? notinrange : gauge.getName();
192 232
193 resultData.addRow(km, flowDepth, flowDepthTkh, tkh, wst, discharge, wstLabel, gaugeLabel, meanBedHeight, bedHeightLabel, location); 233 resultData.addRow(km, flowDepth, flowDepthTkh, kind, tkh, tkhUp, tkhDown, wst, discharge, wstLabel, gaugeLabel, meanBedHeight, bedHeightLabel,
234 location);
194 } 235 }
195 catch (final FunctionEvaluationException e) { 236 catch (final FunctionEvaluationException e) {
196 /* should only happen if out of range */ 237 /* should only happen if out of range */
197 e.printStackTrace(); 238 e.printStackTrace();
198 /* simply ignore */ 239 /* simply ignore */

http://dive4elements.wald.intevation.org