comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.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 183f42641ab6
comparison
equal deleted inserted replaced
8947:86650594f051 8948:a4f1ac81f26d
12 import org.apache.commons.lang.math.DoubleRange; 12 import org.apache.commons.lang.math.DoubleRange;
13 import org.apache.commons.math.ArgumentOutsideDomainException; 13 import org.apache.commons.math.ArgumentOutsideDomainException;
14 import org.dive4elements.artifacts.CallContext; 14 import org.dive4elements.artifacts.CallContext;
15 import org.dive4elements.river.artifacts.model.Calculation; 15 import org.dive4elements.river.artifacts.model.Calculation;
16 import org.dive4elements.river.artifacts.resources.Resources; 16 import org.dive4elements.river.artifacts.resources.Resources;
17 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultRow;
18 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
17 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; 19 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder;
18 import org.dive4elements.river.model.River; 20 import org.dive4elements.river.model.River;
19 21
20 /** 22 /**
21 * @author Gernot Belger 23 * @author Gernot Belger
142 144
143 return Double.NaN; 145 return Double.NaN;
144 } 146 }
145 } 147 }
146 148
147 public Tkh getTkh(final double km) { 149 public void calculateTkh(final double km, final SInfoResultRow row) {
150
151 row.putValue(SInfoResultType.station, km);
148 152
149 final SoilKind kind = getSoilKind(km); 153 final SoilKind kind = getSoilKind(km);
154 row.putValue(SInfoResultType.soilkind, kind);
150 155
151 final double wst = this.waterlevelProvider.getWaterlevel(km); 156 final double wst = this.waterlevelProvider.getWaterlevel(km);
157 row.putValue(SInfoResultType.waterlevel, wst);
152 158
153 final double meanBedHeight = this.bedHeightsProvider.getMeanBedHeight(km); 159 final double meanBedHeight = this.bedHeightsProvider.getMeanBedHeight(km);
160 row.putValue(SInfoResultType.meanBedHeight, meanBedHeight);
154 161
155 final double flowDepth = wst - meanBedHeight; 162 final double flowDepth = wst - meanBedHeight;
163 row.putValue(SInfoResultType.flowdepth, flowDepth);
156 164
157 final double discharge = this.dischargeProvider.getDischarge(km); 165 final double discharge = this.dischargeProvider.getDischarge(km);
166 row.putValue(SInfoResultType.discharge, discharge);
158 if (Double.isNaN(discharge)) 167 if (Double.isNaN(discharge))
159 return new Tkh(km, wst, meanBedHeight, flowDepth, Double.NaN, kind); 168 return;
160 169
161 if (!this.hasTkh()) 170 if (!this.hasTkh())
162 return new Tkh(km, wst, meanBedHeight, flowDepth, Double.NaN, kind); 171 return;
163 172
164 final double d50 = getBedMeasurement(km); 173 final double d50 = getBedMeasurement(km);
165 if (Double.isNaN(d50)) 174 if (Double.isNaN(d50))
166 return new Tkh(km, wst, meanBedHeight, flowDepth, discharge, kind); 175 return;
176 row.putValue(SInfoResultType.d50, d50);
167 177
168 if (!this.flowVelocitiesFinder.findKmQValues(km, discharge)) { 178 if (!this.flowVelocitiesFinder.findKmQValues(km, discharge)) {
169 // TODO: ggf. station in Fehlermeldung? 179 // TODO: ggf. station in Fehlermeldung?
170 final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingVelocity", null, this.problemLabel); 180 final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingVelocity", null, this.problemLabel);
171 this.problems.addProblem(km, message); 181 this.problems.addProblem(km, message);
172 // FIXME: cumulate problems to one message? 182 // FIXME: cumulate problems to one message?
173 return new Tkh(km, wst, meanBedHeight, flowDepth, discharge, kind); 183 return;
174 } 184 }
175 185
176 final double velocity = this.flowVelocitiesFinder.getFindVmainFound(); 186 final double velocity = this.flowVelocitiesFinder.getFindVmainFound();
187 row.putValue(SInfoResultType.velocity, velocity);
188
177 final double tau = this.flowVelocitiesFinder.getFindTauFound(); 189 final double tau = this.flowVelocitiesFinder.getFindTauFound();
190 row.putValue(SInfoResultType.tau, tau);
178 191
179 final double tkh = calculateTkh(wst - meanBedHeight, velocity, d50, tau); 192 final double tkh = calculateTkh(wst - meanBedHeight, velocity, d50, tau);
180 double tkhUp; 193 row.putValue(SInfoResultType.tkh, tkh);
181 double tkhDown; 194
182 switch (kind) { 195 switch (kind) {
183 case starr: 196 case starr:
184 tkhUp = tkh; 197 row.putValue(SInfoResultType.tkhup, tkh);
185 tkhDown = 0; 198 row.putValue(SInfoResultType.tkhdown, 0.0);
186 break; 199 break;
187 200
188 case mobil: 201 case mobil:
189 default: 202 default:
190 tkhUp = tkh / 2; 203 row.putValue(SInfoResultType.tkhup, tkh / 2);
191 tkhDown = -tkh / 2; 204 row.putValue(SInfoResultType.tkhdown, -tkh / 2);
192 break; 205 break;
193 } 206 }
194 207
195 final double flowDepthTkh = calculateFlowDepthTkh(tkhUp, kind, wst, meanBedHeight); 208 final double flowDepthTkh = calculateFlowDepthTkh(tkh, kind, wst, meanBedHeight);
196 209 row.putValue(SInfoResultType.flowdepthtkh, flowDepthTkh);
197 return new Tkh(km, wst, meanBedHeight, flowDepth, flowDepthTkh, discharge, kind, tkh, tkhUp, tkhDown, velocity, d50, tau);
198 } 210 }
199 211
200 /** 212 /**
201 * Calculates a transport body height 213 * Calculates a transport body height
202 * 214 *

http://dive4elements.wald.intevation.org