Mercurial > dive4elements > river
changeset 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 | 253e7f70dd0c |
children | cfed96c53e9a |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java |
diffstat | 2 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Sep 21 07:50:26 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Sep 21 09:22:51 2012 +0000 @@ -1,3 +1,10 @@ +2012-09-20 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Fix issue886 (do not show waterline if out of range). + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Do not extrapolate waterlines. + 2012-09-20 Felix Wolfsteller <felix.wolfsteller@intevation.de> Better Partial issue880 (diverse DC).
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Sep 21 07:50:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Sep 21 09:22:51 2012 +0000 @@ -647,18 +647,28 @@ // Find W at km, linear naive approach. WQKms triple = wqkms[idx]; - int old_idx = 0; - if (triple.size() == 0) { logger.warn("Calculation of waterline is empty."); return Lines.createWaterLines(points, 0.0f); } + // Early abort if we would need to extrapolate. + int T = triple.size(); + double max_km = triple.getKm(T-1), min_km = triple.getKm(0); + if (wishKM < min_km || wishKM > max_km) { + // TODO Does this have to be done in the other WaterlineArtifact + // implementations, too? + logger.warn("Will not extrapolate waterlevels."); + return Lines.createWaterLines(points, 0.0f); + } + + int old_idx = 0; + // Linear seach in WQKms for closest km. double old_dist_wish = Math.abs(wishKM - triple.getKm(0)); double last_w = triple.getW(0); - for (int i = 0, T = triple.size(); i < T; i++) { + for (int i = 0; i < T; i++) { double diff = Math.abs(wishKM - triple.getKm(i)); if (diff > old_dist_wish) { break;