Mercurial > dive4elements > river
changeset 3903:0623cdf32b38
Document issue880
flys-artifacts/trunk@5568 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Sat, 22 Sep 2012 09:55:01 +0000 (2012-09-22) |
parents | da48e33f4241 |
children | 2d2ca7bf70a7 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java |
diffstat | 2 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Sat Sep 22 07:47:12 2012 +0000 +++ b/flys-artifacts/ChangeLog Sat Sep 22 09:55:01 2012 +0000 @@ -1,3 +1,10 @@ +2012-09-22 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Document issue880 (extrapolation of wkms). + + * src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java: + Do not extrapolate, mention further issues with the code. + 2012-09-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiffYearResult.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Sat Sep 22 07:47:12 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Sat Sep 22 09:55:01 2012 +0000 @@ -303,12 +303,36 @@ * @return W in wkms that is closer to km than to next and prev, or Double.NaN. */ public double getWAtCloseKm(WKms wkms, double km, double next, double prev) { + // TODO symbolic "-1" pr next/prev is a bad idea (tm), as we compare + // distances to these values later. + // TODO issue888 + int size = wkms.size(); for (int i = 0; i < size; i++) { double wkmsKm = wkms.getKm(i); double dist = Distance.distance(wkmsKm, km); - if ((prev == -1d || dist <= Distance.distance(wkmsKm, prev)) - && (next == -1d || dist <= Distance.distance(wkmsKm, next))) { + if (dist == 0d) { + return wkms.getW(i); + } + + // Problematic Cases: + // X == km , | and | == prev and next, (?) == wkmsKm + // + // Standard case: + // ----------|----X-----|------- + // (1) (2) (3) (4) + // + // With prev==-1 + // -1 ------X-------|------ + // (5) (6) (7) + // + // With next==-1 + // + // ---|-----X----- -1 + // (8) (9) (10) + + if (dist <= Distance.distance(wkmsKm, prev) + && dist <= Distance.distance(wkmsKm, next)) { return wkms.getW(i); } }