Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 2624:3f24865082da
Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
flys-artifacts/trunk@4212 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 11 Apr 2012 10:14:13 +0000 |
parents | 71086a3a1c5f |
children | 9d2a06c3a134 |
comparison
equal
deleted
inserted
replaced
2623:c4591312f3d3 | 2624:3f24865082da |
---|---|
275 | 275 |
276 ui.appendChild(state.describeStatic(this, doc, ui, context, uuid)); | 276 ui.appendChild(state.describeStatic(this, doc, ui, context, uuid)); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 protected static boolean reportGeneratedWs( | |
281 Calculation report, | |
282 double [] ws | |
283 ) { | |
284 if (ws == null || ws.length < 2) { | |
285 return false; | |
286 } | |
287 | |
288 double lastW = ws[0]; | |
289 boolean alreadyReported = false; | |
290 | |
291 for (int i = 1; i < ws.length; ++i) { | |
292 if (Math.abs(lastW - ws[i]) < 1e-5) { | |
293 if (!alreadyReported) { | |
294 alreadyReported = true; | |
295 report.addProblem("more.than.one.q.for.w", ws[i]); | |
296 } | |
297 } | |
298 else { | |
299 alreadyReported = false; | |
300 } | |
301 lastW = ws[i]; | |
302 } | |
303 | |
304 return true; | |
305 } | |
306 | |
280 | 307 |
281 // | 308 // |
282 // METHODS FOR RETRIEVING COMPUTED DATA FOR DIFFERENT CHART TYPES | 309 // METHODS FOR RETRIEVING COMPUTED DATA FOR DIFFERENT CHART TYPES |
283 // | 310 // |
284 | 311 |
302 } | 329 } |
303 | 330 |
304 double[] qs = getQs(); | 331 double[] qs = getQs(); |
305 double[] ws = null; | 332 double[] ws = null; |
306 boolean qSel = true; | 333 boolean qSel = true; |
334 | |
335 Calculation report = new Calculation(); | |
307 | 336 |
308 if (qs == null) { | 337 if (qs == null) { |
309 logger.debug("Determine Q values based on a set of W values."); | 338 logger.debug("Determine Q values based on a set of W values."); |
310 qSel = false; | 339 qSel = false; |
311 ws = getWs(); | 340 ws = getWs(); |
313 if (qws == null || qws.length == 0) { | 342 if (qws == null || qws.length == 0) { |
314 return error(new WQKms[0], "converting.ws.to.qs.failed"); | 343 return error(new WQKms[0], "converting.ws.to.qs.failed"); |
315 } | 344 } |
316 qs = qws[0]; | 345 qs = qws[0]; |
317 | 346 |
318 if (qws[1] != null) { // If new ws where generated. | 347 if (reportGeneratedWs(report, qws[1])) { |
319 // TODO: Inform user! | |
320 ws = qws[1]; | 348 ws = qws[1]; |
321 } | 349 } |
322 } | 350 } |
323 | 351 |
324 WstValueTable wst = WstValueTableFactory.getTable(river); | 352 WstValueTable wst = WstValueTableFactory.getTable(river); |
349 | 377 |
350 logger.debug( | 378 logger.debug( |
351 "reference gauge: " + gauge.getName() + " (km " + refKm + ")"); | 379 "reference gauge: " + gauge.getName() + " (km " + refKm + ")"); |
352 } | 380 } |
353 | 381 |
354 return computeWaterlevelData(kms, qs, ws, wst, refKm); | 382 return computeWaterlevelData(kms, qs, ws, wst, refKm, report); |
355 } | 383 } |
356 | 384 |
357 | 385 |
358 /** | 386 /** |
359 * Computes the data of a waterlevel computation based on the interpolation | 387 * Computes the data of a waterlevel computation based on the interpolation |
368 public static CalculationResult computeWaterlevelData( | 396 public static CalculationResult computeWaterlevelData( |
369 double [] kms, | 397 double [] kms, |
370 double [] qs, | 398 double [] qs, |
371 double [] ws, | 399 double [] ws, |
372 WstValueTable wst, | 400 WstValueTable wst, |
373 double refKm | 401 double refKm, |
402 Calculation report | |
374 ) { | 403 ) { |
375 logger.info("WINFOArtifact.computeWaterlevelData"); | 404 logger.info("WINFOArtifact.computeWaterlevelData"); |
376 | 405 |
377 Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm); | 406 Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm); |
407 | |
408 if (report != null) { | |
409 calc1.addProblems(report); | |
410 } | |
378 | 411 |
379 return calc1.calculate(wst); | 412 return calc1.calculate(wst); |
380 } | 413 } |
381 | 414 |
382 | 415 |