comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 649:44175d4720f8

Fix crashes in back jump correction. flys-artifacts/trunk@2038 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 01 Jun 2011 09:57:22 +0000
parents 433f67a076aa
children 913b52064449
comparison
equal deleted inserted replaced
648:d4c4fefb095b 649:44175d4720f8
533 ? new double [] { max, min } 533 ? new double [] { max, min }
534 : new double [] { min, max }; 534 : new double [] { min, max };
535 535
536 } 536 }
537 537
538 protected static double [] extractBoundsKm(River river, double [][] segments) {
539
540 if (segments.length == 2) {
541 return getBounds(segments);
542 }
543
544 TDoubleArrayList bounds = new TDoubleArrayList();
545
546 bounds.add(Math.min(segments[0][0], segments[0][1]));
547
548 for (int i = 1; i < segments.length-1; ++i) {
549 double [] segment = segments[i];
550
551 Gauge gauge = river.determineGauge(segment[0], segment[1]);
552
553 if (gauge == null) {
554 logger.warn("no gauge found between " +
555 segment[0] + " and " + segment[1]);
556 bounds.add(0.5*(segment[0] + segment[1]));
557 }
558 else {
559 bounds.add(gauge.getStation().doubleValue());
560 }
561 }
562
563 bounds.add(Math.max(
564 segments[segments.length-1][0],
565 segments[segments.length-1][1]));
566
567 return bounds.toNativeArray();
568 }
569
538 /** 570 /**
539 * Returns the data computed by the discharge longitudinal section 571 * Returns the data computed by the discharge longitudinal section
540 * computation. 572 * computation.
541 * 573 *
542 * @return an array of WQKms object - one object for each given Q value. 574 * @return an array of WQKms object - one object for each given Q value.
592 } 624 }
593 } 625 }
594 626
595 // more than one segment 627 // more than one segment
596 628
597 double [] boundKms; 629 double [] boundKms = extractBoundsKm(river, segments);
598 630
599 if (segments.length == 2) {
600 boundKms = getBounds(segments);
601 }
602 else {
603 TDoubleArrayList bounds = new TDoubleArrayList();
604
605 bounds.add(Math.min(segments[0][0], segments[0][1]));
606
607 for (int i = 1; i < segments.length-1; ++i) {
608 double [] segment = segments[i];
609
610 Gauge gauge = river.determineGauge(segment[0], segment[1]);
611
612 if (gauge == null) {
613 logger.warn("no gauge found between " +
614 segment[0] + " and " + segment[1]);
615 bounds.add(0.5*(segment[0] + segment[1]));
616 }
617 else {
618 bounds.add(gauge.getStation().doubleValue());
619 }
620 }
621
622 bounds.add(Math.max(
623 segments[segments.length-1][0],
624 segments[segments.length-1][1]));
625
626 boundKms = bounds.toNativeArray();
627 }
628 631
629 if (logger.isDebugEnabled()) { 632 if (logger.isDebugEnabled()) {
630 logger.debug("bound kms: " + joinDoubles(boundKms)); 633 logger.debug("bound kms: " + joinDoubles(boundKms));
631 } 634 }
632 635

http://dive4elements.wald.intevation.org