comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 677:a95f34f1f39a

Added error reporting to 'Abflusskurve' calculation. flys-artifacts/trunk@2101 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 10 Jun 2011 14:24:15 +0000
parents c501f27c1f71
children 19a3185822a4
comparison
equal deleted inserted replaced
676:c501f27c1f71 677:a95f34f1f39a
32 import de.intevation.flys.artifacts.model.WQDay; 32 import de.intevation.flys.artifacts.model.WQDay;
33 import de.intevation.flys.artifacts.model.WQKms; 33 import de.intevation.flys.artifacts.model.WQKms;
34 import de.intevation.flys.artifacts.model.WstValueTable; 34 import de.intevation.flys.artifacts.model.WstValueTable;
35 import de.intevation.flys.artifacts.model.WstValueTable.QPosition; 35 import de.intevation.flys.artifacts.model.WstValueTable.QPosition;
36 import de.intevation.flys.artifacts.model.WstValueTableFactory; 36 import de.intevation.flys.artifacts.model.WstValueTableFactory;
37 import de.intevation.flys.artifacts.model.Calculation2;
37 import de.intevation.flys.artifacts.model.Calculation3; 38 import de.intevation.flys.artifacts.model.Calculation3;
38 import de.intevation.flys.artifacts.model.Calculation4; 39 import de.intevation.flys.artifacts.model.Calculation4;
39 import de.intevation.flys.artifacts.model.Segment; 40 import de.intevation.flys.artifacts.model.Segment;
40 41
41 import gnu.trove.TDoubleArrayList; 42 import gnu.trove.TDoubleArrayList;
453 454
454 WQKms wqkms = computeDischargeCurveData(wst, locations[0]); 455 WQKms wqkms = computeDischargeCurveData(wst, locations[0]);
455 456
456 // TODO Introduce a caching mechanism here! 457 // TODO Introduce a caching mechanism here!
457 458
458 setComputedDischargeCurveNames(wqkms, locations[0]);
459
460 return wqkms; 459 return wqkms;
461 }
462
463
464 /**
465 * Sets the name of the computed discharge curve data.
466 *
467 * @param wqkms The computed WQKms object.
468 * @param l The location used for the computation.
469 */
470 public static void setComputedDischargeCurveNames(WQKms wqkms, double l) {
471 wqkms.setName(Double.toString(l));
472 } 460 }
473 461
474 462
475 /** 463 /**
476 * Computes the data used to create computed discharge curves. 464 * Computes the data used to create computed discharge curves.
485 WstValueTable wst, 473 WstValueTable wst,
486 double location) 474 double location)
487 { 475 {
488 logger.info("WINFOArtifact.computeDischargeCurveData"); 476 logger.info("WINFOArtifact.computeDischargeCurveData");
489 477
490 double[][] wqs = wst.interpolateWQ(location); 478 Calculation2 calculation = new Calculation2(location);
491 479
492 if (wqs == null) { 480 WQKms wqkms = calculation.calculate(wst);
493 logger.error("Cannot compute discharge curve data."); 481
494 return null; 482 // TODO: Report errors to the user
495 }
496
497 double[] ws = wqs[0];
498 double[] qs = wqs[1];
499
500 WQKms wqkms = new WQKms(ws.length);
501
502 for (int i = 0; i < ws.length; i++) {
503 wqkms.add(ws[i], qs[i], location);
504 }
505 483
506 return wqkms; 484 return wqkms;
507 } 485 }
508 486
509 private static final double [] getBounds(double [][] segments) { 487 private static final double [] getBounds(double [][] segments) {

http://dive4elements.wald.intevation.org