comparison artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents f4421417f3e1
children 27d42c9ee367
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
70 */ 70 */
71 public class WINFOArtifact 71 public class WINFOArtifact
72 extends D4EArtifact 72 extends D4EArtifact
73 implements FacetTypes, WaterLineArtifact { 73 implements FacetTypes, WaterLineArtifact {
74 74
75 /** The logger for this class. */ 75 /** The log for this class. */
76 private static Logger logger = Logger.getLogger(WINFOArtifact.class); 76 private static Logger log = Logger.getLogger(WINFOArtifact.class);
77 77
78 /** The name of the artifact. */ 78 /** The name of the artifact. */
79 public static final String ARTIFACT_NAME = "winfo"; 79 public static final String ARTIFACT_NAME = "winfo";
80 80
81 /** XPath */ 81 /** XPath */
191 * 191 *
192 * @return an array of data triples that consist of W, Q and Kms. 192 * @return an array of data triples that consist of W, Q and Kms.
193 */ 193 */
194 public CalculationResult getWaterlevelData(CallContext context) 194 public CalculationResult getWaterlevelData(CallContext context)
195 { 195 {
196 logger.debug("WINFOArtifact.getWaterlevelData"); 196 log.debug("WINFOArtifact.getWaterlevelData");
197 197
198 String calculationMode = getDataAsString("calculation_mode"); 198 String calculationMode = getDataAsString("calculation_mode");
199 199
200 // If this WINFO-Artifact has a calculation trait. 200 // If this WINFO-Artifact has a calculation trait.
201 if (calculationMode != null) { 201 if (calculationMode != null) {
210 else if (calculationMode.equals("calc.w.differences")) { 210 else if (calculationMode.equals("calc.w.differences")) {
211 return (CalculationResult) 211 return (CalculationResult)
212 this.compute(context, ComputeType.ADVANCE, true); 212 this.compute(context, ComputeType.ADVANCE, true);
213 } 213 }
214 else { 214 else {
215 logger.warn("Unhandled calculation_mode " + calculationMode); 215 log.warn("Unhandled calculation_mode " + calculationMode);
216 } 216 }
217 } 217 }
218 218
219 // Otherwise get it from parameterization. 219 // Otherwise get it from parameterization.
220 River river = RiverUtils.getRiver(this); 220 River river = RiverUtils.getRiver(this);
232 boolean qSel = true; 232 boolean qSel = true;
233 233
234 Calculation report = new Calculation(); 234 Calculation report = new Calculation();
235 235
236 if (qs == null) { 236 if (qs == null) {
237 logger.debug("Determine Q values based on a set of W values."); 237 log.debug("Determine Q values based on a set of W values.");
238 qSel = false; 238 qSel = false;
239 ws = getWs(); 239 ws = getWs();
240 double [][] qws = getQsForWs(ws); 240 double [][] qws = getQsForWs(ws);
241 if (qws == null || qws.length == 0) { 241 if (qws == null || qws.length == 0) {
242 return error(new WQKms[0], "converting.ws.to.qs.failed"); 242 return error(new WQKms[0], "converting.ws.to.qs.failed");
261 261
262 double refKm; 262 double refKm;
263 263
264 if (isFreeQ() || isFreeW()) { 264 if (isFreeQ() || isFreeW()) {
265 refKm = range[0]; 265 refKm = range[0];
266 logger.debug("'free' calculation (km " + refKm + ")"); 266 log.debug("'free' calculation (km " + refKm + ")");
267 } 267 }
268 else { 268 else {
269 Gauge gauge = river.determineGaugeByPosition(range[0]); 269 Gauge gauge = river.determineGaugeByPosition(range[0]);
270 if (gauge == null) { 270 if (gauge == null) {
271 return error( 271 return error(
272 new WQKms[0], "no.gauge.found.for.km", range[0]); 272 new WQKms[0], "no.gauge.found.for.km", range[0]);
273 } 273 }
274 274
275 refKm = gauge.getStation().doubleValue(); 275 refKm = gauge.getStation().doubleValue();
276 276
277 logger.debug( 277 log.debug(
278 "reference gauge: " + gauge.getName() + " (km " + refKm + ")"); 278 "reference gauge: " + gauge.getName() + " (km " + refKm + ")");
279 } 279 }
280 280
281 return computeWaterlevelData(kms, qs, ws, wst, refKm, report); 281 return computeWaterlevelData(kms, qs, ws, wst, refKm, report);
282 } 282 }
298 double [] ws, 298 double [] ws,
299 WstValueTable wst, 299 WstValueTable wst,
300 double refKm, 300 double refKm,
301 Calculation report 301 Calculation report
302 ) { 302 ) {
303 logger.info("WINFOArtifact.computeWaterlevelData"); 303 log.info("WINFOArtifact.computeWaterlevelData");
304 304
305 Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm); 305 Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm);
306 306
307 if (report != null) { 307 if (report != null) {
308 calc1.addProblems(report); 308 calc1.addProblems(report);
316 * Returns the data that is computed by a duration curve computation. 316 * Returns the data that is computed by a duration curve computation.
317 * 317 *
318 * @return the data computed by a duration curve computation. 318 * @return the data computed by a duration curve computation.
319 */ 319 */
320 public CalculationResult getDurationCurveData() { 320 public CalculationResult getDurationCurveData() {
321 logger.debug("WINFOArtifact.getDurationCurveData"); 321 log.debug("WINFOArtifact.getDurationCurveData");
322 322
323 River r = RiverUtils.getRiver(this); 323 River r = RiverUtils.getRiver(this);
324 324
325 if (r == null) { 325 if (r == null) {
326 return error(null, "no.river.selected"); 326 return error(null, "no.river.selected");
359 public static CalculationResult computeDurationCurveData( 359 public static CalculationResult computeDurationCurveData(
360 Gauge gauge, 360 Gauge gauge,
361 WstValueTable wst, 361 WstValueTable wst,
362 double location) 362 double location)
363 { 363 {
364 logger.info("WINFOArtifact.computeDurationCurveData"); 364 log.info("WINFOArtifact.computeDurationCurveData");
365 365
366 Object[] obj = gauge.fetchDurationCurveData(); 366 Object[] obj = gauge.fetchDurationCurveData();
367 367
368 int[] days = (int[]) obj[0]; 368 int[] days = (int[]) obj[0];
369 double[] qs = (double[]) obj[1]; 369 double[] qs = (double[]) obj[1];
380 * @return the data computed by a discharge curve computation. 380 * @return the data computed by a discharge curve computation.
381 */ 381 */
382 public CalculationResult getComputedDischargeCurveData() 382 public CalculationResult getComputedDischargeCurveData()
383 throws NullPointerException 383 throws NullPointerException
384 { 384 {
385 logger.debug("WINFOArtifact.getComputedDischargeCurveData"); 385 log.debug("WINFOArtifact.getComputedDischargeCurveData");
386 386
387 River r = RiverUtils.getRiver(this); 387 River r = RiverUtils.getRiver(this);
388 388
389 if (r == null) { 389 if (r == null) {
390 return error(new WQKms[0], "no.river.selected"); 390 return error(new WQKms[0], "no.river.selected");
418 */ 418 */
419 public static CalculationResult computeDischargeCurveData( 419 public static CalculationResult computeDischargeCurveData(
420 WstValueTable wst, 420 WstValueTable wst,
421 double location) 421 double location)
422 { 422 {
423 logger.info("WINFOArtifact.computeDischargeCurveData"); 423 log.info("WINFOArtifact.computeDischargeCurveData");
424 424
425 Calculation2 calculation = new Calculation2(location); 425 Calculation2 calculation = new Calculation2(location);
426 426
427 return calculation.calculate(wst); 427 return calculation.calculate(wst);
428 } 428 }
479 /** Get reference (start) km. */ 479 /** Get reference (start) km. */
480 public Double getReferenceStartKm() { 480 public Double getReferenceStartKm() {
481 StateData sd = getData("reference_startpoint"); 481 StateData sd = getData("reference_startpoint");
482 482
483 if (sd == null) { 483 if (sd == null) {
484 logger.warn("no reference start given."); 484 log.warn("no reference start given.");
485 return null; 485 return null;
486 } 486 }
487 487
488 logger.debug("Reference start km given: " + sd.getValue()); 488 log.debug("Reference start km given: " + sd.getValue());
489 489
490 String input = (String) sd.getValue(); 490 String input = (String) sd.getValue();
491 491
492 if (input == null || (input = input.trim()).length() == 0) { 492 if (input == null || (input = input.trim()).length() == 0) {
493 logger.warn("reference start string is empty."); 493 log.warn("reference start string is empty.");
494 return null; 494 return null;
495 } 495 }
496 496
497 try { 497 try {
498 return Double.valueOf(input); 498 return Double.valueOf(input);
499 } 499 }
500 catch (NumberFormatException nfe) { 500 catch (NumberFormatException nfe) {
501 logger.warn("reference start string is not numeric."); 501 log.warn("reference start string is not numeric.");
502 } 502 }
503 503
504 return null; 504 return null;
505 } 505 }
506 506
510 */ 510 */
511 public double [] getReferenceEndKms() { 511 public double [] getReferenceEndKms() {
512 StateData sd = getData("reference_endpoint"); 512 StateData sd = getData("reference_endpoint");
513 513
514 if (sd == null) { 514 if (sd == null) {
515 logger.warn("no reference end given."); 515 log.warn("no reference end given.");
516 return null; 516 return null;
517 } 517 }
518 else { 518 else {
519 logger.debug("Reference end km : " + sd.getValue()); 519 log.debug("Reference end km : " + sd.getValue());
520 } 520 }
521 521
522 String input = (String) sd.getValue(); 522 String input = (String) sd.getValue();
523 523
524 if (input == null || (input = input.trim()).length() == 0) { 524 if (input == null || (input = input.trim()).length() == 0) {
525 logger.warn("reference end string is empty."); 525 log.warn("reference end string is empty.");
526 return null; 526 return null;
527 } 527 }
528 528
529 TDoubleArrayList endKms = new TDoubleArrayList(); 529 TDoubleArrayList endKms = new TDoubleArrayList();
530 530
534 if (!endKms.contains(km)) { 534 if (!endKms.contains(km)) {
535 endKms.add(km); 535 endKms.add(km);
536 } 536 }
537 } 537 }
538 catch (NumberFormatException nfe) { 538 catch (NumberFormatException nfe) {
539 logger.warn("reference end string is not numeric."); 539 log.warn("reference end string is not numeric.");
540 } 540 }
541 } 541 }
542 542
543 return endKms.toNativeArray(); 543 return endKms.toNativeArray();
544 } 544 }
558 558
559 // Find W/C at km, linear naive approach. 559 // Find W/C at km, linear naive approach.
560 WQCKms triple = (WQCKms) wqckms[idx-1]; 560 WQCKms triple = (WQCKms) wqckms[idx-1];
561 561
562 if (triple.size() == 0) { 562 if (triple.size() == 0) {
563 logger.warn("Calculation of c/waterline is empty."); 563 log.warn("Calculation of c/waterline is empty.");
564 return Lines.createWaterLines(points, 0.0f); 564 return Lines.createWaterLines(points, 0.0f);
565 } 565 }
566 566
567 // Linear seach in WQKms for closest km. 567 // Linear seach in WQKms for closest km.
568 double old_dist_wish = Math.abs(wishKM - triple.getKm(0)); 568 double old_dist_wish = Math.abs(wishKM - triple.getKm(0));
593 * in the form {{x1, x2} {y1, y2}} ). 593 * in the form {{x1, x2} {y1, y2}} ).
594 */ 594 */
595 @Override 595 @Override
596 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl, 596 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl,
597 double nextIgnored, double prevIgnored, CallContext context) { 597 double nextIgnored, double prevIgnored, CallContext context) {
598 logger.debug("getWaterLines(" + idx + ")"); 598 log.debug("getWaterLines(" + idx + ")");
599 599
600 List<Point2D> points = csl.getPoints(); 600 List<Point2D> points = csl.getPoints();
601 601
602 // Need W at km 602 // Need W at km
603 Object waterlevelResult = getWaterlevelData(context).getData(); 603 Object waterlevelResult = getWaterlevelData(context).getData();
609 else { 609 else {
610 wqkms = (WQKms[]) waterlevelResult; 610 wqkms = (WQKms[]) waterlevelResult;
611 } 611 }
612 612
613 if (wqkms.length == 0) { 613 if (wqkms.length == 0) {
614 logger.error("No WQKms found."); 614 log.error("No WQKms found.");
615 return Lines.createWaterLines(points, 0.0f); 615 return Lines.createWaterLines(points, 0.0f);
616 } 616 }
617 617
618 if (wqkms.length <= idx) { 618 if (wqkms.length <= idx) {
619 logger.error("getWaterLines() requested index (" 619 log.error("getWaterLines() requested index ("
620 + idx + " not found."); 620 + idx + " not found.");
621 return waterLineC(idx, csl); 621 return waterLineC(idx, csl);
622 } 622 }
623 623
624 // Find W at km, linear naive approach. 624 // Find W at km, linear naive approach.
626 626
627 // Find index of km. 627 // Find index of km.
628 double wishKM = csl.getKm(); 628 double wishKM = csl.getKm();
629 629
630 if (triple.size() == 0) { 630 if (triple.size() == 0) {
631 logger.warn("Calculation of waterline is empty."); 631 log.warn("Calculation of waterline is empty.");
632 return Lines.createWaterLines(points, 0.0f); 632 return Lines.createWaterLines(points, 0.0f);
633 } 633 }
634 634
635 // Early abort if we would need to extrapolate. 635 // Early abort if we would need to extrapolate.
636 int T = triple.size(); 636 int T = triple.size();
637 double max_km = triple.getKm(T-1), min_km = triple.getKm(0); 637 double max_km = triple.getKm(T-1), min_km = triple.getKm(0);
638 if (wishKM < min_km || wishKM > max_km) { 638 if (wishKM < min_km || wishKM > max_km) {
639 // TODO Does this have to be done in the other WaterlineArtifact 639 // TODO Does this have to be done in the other WaterlineArtifact
640 // implementations, too? 640 // implementations, too?
641 logger.warn("Will not extrapolate waterlevels."); 641 log.warn("Will not extrapolate waterlevels.");
642 return Lines.createWaterLines(points, 0.0f); 642 return Lines.createWaterLines(points, 0.0f);
643 } 643 }
644 644
645 int old_idx = 0; 645 int old_idx = 0;
646 646
670 * @return an array of Q values. 670 * @return an array of Q values.
671 */ 671 */
672 public double [][] getQsForWs(double[] ws) { 672 public double [][] getQsForWs(double[] ws) {
673 673
674 if (ws == null) { 674 if (ws == null) {
675 logger.error("getQsForWs: ws == null"); 675 log.error("getQsForWs: ws == null");
676 return null; 676 return null;
677 } 677 }
678 678
679 boolean debug = logger.isDebugEnabled(); 679 boolean debug = log.isDebugEnabled();
680 680
681 if (debug) { 681 if (debug) {
682 logger.debug("D4EArtifact.getQsForWs"); 682 log.debug("D4EArtifact.getQsForWs");
683 } 683 }
684 684
685 River r = RiverUtils.getRiver(this); 685 River r = RiverUtils.getRiver(this);
686 if (r == null) { 686 if (r == null) {
687 logger.warn("no river found"); 687 log.warn("no river found");
688 return null; 688 return null;
689 } 689 }
690 690
691 RangeAccess rangeAccess = new RangeAccess(this); 691 RangeAccess rangeAccess = new RangeAccess(this);
692 double [] range = rangeAccess.getKmRange(); 692 double [] range = rangeAccess.getKmRange();
693 if (range == null) { 693 if (range == null) {
694 logger.warn("no ranges found"); 694 log.warn("no ranges found");
695 return null; 695 return null;
696 } 696 }
697 697
698 if (isFreeW()) { 698 if (isFreeW()) {
699 logger.debug("Bezugslinienverfahren I: W auf freier Strecke"); 699 log.debug("Bezugslinienverfahren I: W auf freier Strecke");
700 // The simple case of the "Bezugslinienverfahren" 700 // The simple case of the "Bezugslinienverfahren"
701 // "W auf freier Strecke". 701 // "W auf freier Strecke".
702 WstValueTable wst = WstValueTableFactory.getTable(r); 702 WstValueTable wst = WstValueTableFactory.getTable(r);
703 if (wst == null) { 703 if (wst == null) {
704 logger.warn("no wst value table found"); 704 log.warn("no wst value table found");
705 return null; 705 return null;
706 } 706 }
707 double km = range[0]; 707 double km = range[0];
708 708
709 TDoubleArrayList outQs = new TDoubleArrayList(ws.length); 709 TDoubleArrayList outQs = new TDoubleArrayList(ws.length);
712 boolean generatedWs = false; 712 boolean generatedWs = false;
713 713
714 for (int i = 0; i < ws.length; ++i) { 714 for (int i = 0; i < ws.length; ++i) {
715 double w = ws[i]; 715 double w = ws[i];
716 if (debug) { 716 if (debug) {
717 logger.debug("getQsForWs: lookup Q for W: " + w); 717 log.debug("getQsForWs: lookup Q for W: " + w);
718 } 718 }
719 // There could bemore than one Q per W. 719 // There could bemore than one Q per W.
720 double [] qs = wst.findQsForW(km, w); 720 double [] qs = wst.findQsForW(km, w);
721 for (int j = 0; j < qs.length; ++j) { 721 for (int j = 0; j < qs.length; ++j) {
722 outWs.add(ws[i]); 722 outWs.add(ws[i]);
724 } 724 }
725 generatedWs |= qs.length != 1; 725 generatedWs |= qs.length != 1;
726 } 726 }
727 727
728 if (debug) { 728 if (debug) {
729 logger.debug("getQsForWs: number of Qs: " + outQs.size()); 729 log.debug("getQsForWs: number of Qs: " + outQs.size());
730 } 730 }
731 731
732 return new double [][] { 732 return new double [][] {
733 outQs.toNativeArray(), 733 outQs.toNativeArray(),
734 generatedWs ? outWs.toNativeArray() : null }; 734 generatedWs ? outWs.toNativeArray() : null };
735 } 735 }
736 736
737 if (debug) { 737 if (debug) {
738 logger.debug("range: " + Arrays.toString(range)); 738 log.debug("range: " + Arrays.toString(range));
739 } 739 }
740 740
741 Gauge g = r.determineGaugeByPosition(range[0]); 741 Gauge g = r.determineGaugeByPosition(range[0]);
742 if (g == null) { 742 if (g == null) {
743 logger.warn("no gauge found for km: " + range[0]); 743 log.warn("no gauge found for km: " + range[0]);
744 return null; 744 return null;
745 } 745 }
746 746
747 if (debug) { 747 if (debug) {
748 logger.debug("convert w->q with gauge '" + g.getName() + "'"); 748 log.debug("convert w->q with gauge '" + g.getName() + "'");
749 } 749 }
750 750
751 DischargeTable dt = g.fetchMasterDischargeTable(); 751 DischargeTable dt = g.fetchMasterDischargeTable();
752 752
753 if (dt == null) { 753 if (dt == null) {
754 logger.warn("No master discharge table found for gauge '" 754 log.warn("No master discharge table found for gauge '"
755 + g.getName() + "'"); 755 + g.getName() + "'");
756 return null; 756 return null;
757 } 757 }
758 758
759 double [][] values = DischargeTables.loadDischargeTableValues(dt); 759 double [][] values = DischargeTables.loadDischargeTableValues(dt);
763 763
764 boolean generatedWs = false; 764 boolean generatedWs = false;
765 765
766 for (int i = 0; i < ws.length; i++) { 766 for (int i = 0; i < ws.length; i++) {
767 if (Double.isNaN(ws[i])) { 767 if (Double.isNaN(ws[i])) {
768 logger.warn("W is NaN: ignored"); 768 log.warn("W is NaN: ignored");
769 continue; 769 continue;
770 } 770 }
771 double [] qs = DischargeTables.getQsForW(values, ws[i]); 771 double [] qs = DischargeTables.getQsForW(values, ws[i]);
772 772
773 if (qs.length == 0) { 773 if (qs.length == 0) {
774 logger.warn("No Qs found for W = " + ws[i]); 774 log.warn("No Qs found for W = " + ws[i]);
775 } 775 }
776 else { 776 else {
777 for (double q: qs) { 777 for (double q: qs) {
778 wsOut.add(ws[i]); 778 wsOut.add(ws[i]);
779 qsOut.add(q); 779 qsOut.add(q);
796 */ 796 */
797 public boolean isRange() { 797 public boolean isRange() {
798 StateData mode = getData("ld_mode"); 798 StateData mode = getData("ld_mode");
799 799
800 if (mode == null) { 800 if (mode == null) {
801 logger.warn("No mode location/range chosen. Defaults to range."); 801 log.warn("No mode location/range chosen. Defaults to range.");
802 return true; 802 return true;
803 } 803 }
804 804
805 String value = (String) mode.getValue(); 805 String value = (String) mode.getValue();
806 806
833 */ 833 */
834 public double[] getKms(double[] distance) { 834 public double[] getKms(double[] distance) {
835 StateData dStep = getData("ld_step"); 835 StateData dStep = getData("ld_step");
836 836
837 if (dStep == null) { 837 if (dStep == null) {
838 logger.warn("No step width given. Cannot compute Kms."); 838 log.warn("No step width given. Cannot compute Kms.");
839 return null; 839 return null;
840 } 840 }
841 841
842 double step = Double.parseDouble((String) dStep.getValue()); 842 double step = Double.parseDouble((String) dStep.getValue());
843 843
934 else { 934 else {
935 return getWQTriple(); 935 return getWQTriple();
936 } 936 }
937 } 937 }
938 else { 938 else {
939 logger.warn("You try to get Qs, but W has been inserted."); 939 log.warn("You try to get Qs, but W has been inserted.");
940 return null; 940 return null;
941 } 941 }
942 } 942 }
943 943
944 944
978 return false; 978 return false;
979 } 979 }
980 StateData mode = getData("wq_isfree"); 980 StateData mode = getData("wq_isfree");
981 String value = (mode != null) ? (String) mode.getValue() : null; 981 String value = (mode != null) ? (String) mode.getValue() : null;
982 982
983 logger.debug("isFreeQ: " + value); 983 log.debug("isFreeQ: " + value);
984 984
985 return value != null && Boolean.valueOf(value); 985 return value != null && Boolean.valueOf(value);
986 } 986 }
987 987
988 988
998 998
999 if (isQ()) { 999 if (isQ()) {
1000 return getWQForDist(range); 1000 return getWQForDist(range);
1001 } 1001 }
1002 1002
1003 logger.warn("You try to get Qs, but Ws has been inserted."); 1003 log.warn("You try to get Qs, but Ws has been inserted.");
1004 return null; 1004 return null;
1005 } 1005 }
1006 1006
1007 1007
1008 /** 1008 /**
1015 public double[] getWs(double[] range) { 1015 public double[] getWs(double[] range) {
1016 if (isW()) { 1016 if (isW()) {
1017 return getWQForDist(range); 1017 return getWQForDist(range);
1018 } 1018 }
1019 1019
1020 logger.warn("You try to get Ws, but Qs has been inserted."); 1020 log.warn("You try to get Ws, but Qs has been inserted.");
1021 return null; 1021 return null;
1022 } 1022 }
1023 1023
1024 1024
1025 /** 1025 /**
1036 else { 1036 else {
1037 return getWQTriple(); 1037 return getWQTriple();
1038 } 1038 }
1039 } 1039 }
1040 else { 1040 else {
1041 logger.warn("You try to get Ws, but Q has been inserted."); 1041 log.warn("You try to get Ws, but Q has been inserted.");
1042 return null; 1042 return null;
1043 } 1043 }
1044 } 1044 }
1045 1045
1046 /** 1046 /**
1050 * @param dist A 2dim array with lower und upper kilometer values. 1050 * @param dist A 2dim array with lower und upper kilometer values.
1051 * 1051 *
1052 * @return an array of W or Q values. 1052 * @return an array of W or Q values.
1053 */ 1053 */
1054 protected double[] getWQForDist(double[] dist) { 1054 protected double[] getWQForDist(double[] dist) {
1055 logger.debug("Search wq values for range: " + dist[0] + " - " + dist[1]); 1055 log.debug("Search wq values for range: " + dist[0] + " - " + dist[1]);
1056 StateData data = getData("wq_values"); 1056 StateData data = getData("wq_values");
1057 1057
1058 if (data == null) { 1058 if (data == null) {
1059 logger.warn("Missing wq values!"); 1059 log.warn("Missing wq values!");
1060 return null; 1060 return null;
1061 } 1061 }
1062 1062
1063 String dataString = (String) data.getValue(); 1063 String dataString = (String) data.getValue();
1064 String[] ranges = dataString.split(":"); 1064 String[] ranges = dataString.split(":");
1078 for (int i = 0; i < num; i++) { 1078 for (int i = 0; i < num; i++) {
1079 try { 1079 try {
1080 res[i] = Double.parseDouble(values[i]); 1080 res[i] = Double.parseDouble(values[i]);
1081 } 1081 }
1082 catch (NumberFormatException nfe) { 1082 catch (NumberFormatException nfe) {
1083 logger.warn(nfe, nfe); 1083 log.warn(nfe, nfe);
1084 } 1084 }
1085 } 1085 }
1086 1086
1087 return res; 1087 return res;
1088 } 1088 }
1089 } 1089 }
1090 1090
1091 logger.warn("Specified range for WQ not found!"); 1091 log.warn("Specified range for WQ not found!");
1092 1092
1093 return null; 1093 return null;
1094 } 1094 }
1095 1095
1096 1096
1103 protected double[] getWQTriple() { 1103 protected double[] getWQTriple() {
1104 StateData dFrom = getData("wq_from"); 1104 StateData dFrom = getData("wq_from");
1105 StateData dTo = getData("wq_to"); 1105 StateData dTo = getData("wq_to");
1106 1106
1107 if (dFrom == null || dTo == null) { 1107 if (dFrom == null || dTo == null) {
1108 logger.warn("Missing start or end value for range."); 1108 log.warn("Missing start or end value for range.");
1109 return null; 1109 return null;
1110 } 1110 }
1111 1111
1112 double from = Double.parseDouble((String) dFrom.getValue()); 1112 double from = Double.parseDouble((String) dFrom.getValue());
1113 double to = Double.parseDouble((String) dTo.getValue()); 1113 double to = Double.parseDouble((String) dTo.getValue());
1114 1114
1115 StateData dStep = getData("wq_step"); 1115 StateData dStep = getData("wq_step");
1116 1116
1117 if (dStep == null) { 1117 if (dStep == null) {
1118 logger.warn("No step width given. Cannot compute Qs."); 1118 log.warn("No step width given. Cannot compute Qs.");
1119 return null; 1119 return null;
1120 } 1120 }
1121 1121
1122 double step = Double.parseDouble((String) dStep.getValue()); 1122 double step = Double.parseDouble((String) dStep.getValue());
1123 1123
1140 */ 1140 */
1141 protected double[] getSingleWQValues() { 1141 protected double[] getSingleWQValues() {
1142 StateData dSingle = getData("wq_single"); 1142 StateData dSingle = getData("wq_single");
1143 1143
1144 if (dSingle == null) { 1144 if (dSingle == null) {
1145 logger.warn("Cannot determine single WQ values. No data given."); 1145 log.warn("Cannot determine single WQ values. No data given.");
1146 return null; 1146 return null;
1147 } 1147 }
1148 1148
1149 String tmp = (String) dSingle.getValue(); 1149 String tmp = (String) dSingle.getValue();
1150 String[] strValues = tmp.split(" "); 1150 String[] strValues = tmp.split(" ");
1154 for (String strValue: strValues) { 1154 for (String strValue: strValues) {
1155 try { 1155 try {
1156 values.add(Double.parseDouble(strValue)); 1156 values.add(Double.parseDouble(strValue));
1157 } 1157 }
1158 catch (NumberFormatException nfe) { 1158 catch (NumberFormatException nfe) {
1159 logger.warn(nfe, nfe); 1159 log.warn(nfe, nfe);
1160 } 1160 }
1161 } 1161 }
1162 1162
1163 values.sort(); 1163 values.sort();
1164 1164

http://dive4elements.wald.intevation.org