Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 3892:1dc658c3306b
Fix issue886 (no extrapolation of waterlines).
flys-artifacts/trunk@5547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 21 Sep 2012 09:22:51 +0000 |
parents | c0a15547ad76 |
children | e1f81795401f |
comparison
equal
deleted
inserted
replaced
3891:253e7f70dd0c | 3892:1dc658c3306b |
---|---|
645 double wishKM = csl.getKm(); | 645 double wishKM = csl.getKm(); |
646 | 646 |
647 // Find W at km, linear naive approach. | 647 // Find W at km, linear naive approach. |
648 WQKms triple = wqkms[idx]; | 648 WQKms triple = wqkms[idx]; |
649 | 649 |
650 int old_idx = 0; | |
651 | |
652 if (triple.size() == 0) { | 650 if (triple.size() == 0) { |
653 logger.warn("Calculation of waterline is empty."); | 651 logger.warn("Calculation of waterline is empty."); |
654 return Lines.createWaterLines(points, 0.0f); | 652 return Lines.createWaterLines(points, 0.0f); |
655 } | 653 } |
656 | 654 |
655 // Early abort if we would need to extrapolate. | |
656 int T = triple.size(); | |
657 double max_km = triple.getKm(T-1), min_km = triple.getKm(0); | |
658 if (wishKM < min_km || wishKM > max_km) { | |
659 // TODO Does this have to be done in the other WaterlineArtifact | |
660 // implementations, too? | |
661 logger.warn("Will not extrapolate waterlevels."); | |
662 return Lines.createWaterLines(points, 0.0f); | |
663 } | |
664 | |
665 int old_idx = 0; | |
666 | |
657 // Linear seach in WQKms for closest km. | 667 // Linear seach in WQKms for closest km. |
658 double old_dist_wish = Math.abs(wishKM - triple.getKm(0)); | 668 double old_dist_wish = Math.abs(wishKM - triple.getKm(0)); |
659 double last_w = triple.getW(0); | 669 double last_w = triple.getW(0); |
660 | 670 |
661 for (int i = 0, T = triple.size(); i < T; i++) { | 671 for (int i = 0; i < T; i++) { |
662 double diff = Math.abs(wishKM - triple.getKm(i)); | 672 double diff = Math.abs(wishKM - triple.getKm(i)); |
663 if (diff > old_dist_wish) { | 673 if (diff > old_dist_wish) { |
664 break; | 674 break; |
665 } | 675 } |
666 last_w = triple.getW(i); | 676 last_w = triple.getW(i); |