comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 393:befedd7629d5

Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart. flys-artifacts/trunk@1818 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 04 May 2011 08:24:50 +0000
parents 478940d06876
children eb22ffe4d74c
comparison
equal deleted inserted replaced
392:72177020db92 393:befedd7629d5
374 wqday.add(days[i], interpolatedW[i], qs[i]); 374 wqday.add(days[i], interpolatedW[i], qs[i]);
375 } 375 }
376 376
377 return wqday; 377 return wqday;
378 } 378 }
379
380
381 /**
382 * Returns the data that is computed by a discharge curve computation.
383 *
384 * @return the data computed by a discharge curve computation.
385 */
386 public WQKms getComputedDischargeCurveData()
387 throws NullPointerException
388 {
389 logger.debug("WINFOArtifact.getComputedDischargeCurveData");
390
391 River r = getRiver();
392
393 if (r == null) {
394 throw new NullPointerException("Cannot determine river.");
395 }
396
397 double[] locations = getLocations();
398
399 if (locations == null) {
400 throw new NullPointerException("Cannot determine location.");
401 }
402
403 WstValueTable wst = WstValueTable.getTable(r);
404 if (wst == null) {
405 throw new NullPointerException("No Wst found for selected river.");
406 }
407
408 // TODO Introduce a caching mechanism here!
409
410 return computeDischargeCurveData(wst, locations[0]);
411 }
412
413
414 /**
415 * Computes the data used to create computed discharge curves.
416 *
417 * @param wst The WstValueTable that is used for the interpolation.
418 * @param location The location where the computation should be based on.
419 *
420 * @return an object that contains tuples of W/Q values at the specified
421 * location.
422 */
423 public static WQKms computeDischargeCurveData(
424 WstValueTable wst,
425 double location)
426 {
427 logger.info("WINFOArtifact.computeDischargeCurveData");
428
429 double[][] wqs = wst.interpolateWQ(location);
430
431 if (wqs == null) {
432 logger.error("Cannot compute discharge curve data.");
433 return null;
434 }
435
436 double[] ws = wqs[0];
437 double[] qs = wqs[1];
438
439 WQKms wqkms = new WQKms(ws.length);
440
441 for (int i = 0; i < ws.length; i++) {
442 wqkms.add(ws[i], qs[i], location);
443 }
444
445 return wqkms;
446 }
379 } 447 }
380 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 448 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org