# HG changeset patch # User Felix Wolfsteller # Date 1349355284 -7200 # Node ID e4e345d81a650905525f118cd6af32e86da9ffeb # Parent 4bc58d6ee9db6b75e6a71cb5375dc318fb795a22 issue889/2 diff -r 4bc58d6ee9db -r e4e345d81a65 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Oct 04 14:12:03 2012 +0200 +++ b/flys-artifacts/ChangeLog Thu Oct 04 14:54:44 2012 +0200 @@ -1,3 +1,10 @@ +2012-10-04 Felix Wolfsteller + + Fix issue889/2 . + + * flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java: + Do not AIOOB on wsts with one (or zero) value only. + 2012-10-04 Björn Ricks * src/main/resources/messages.properties, @@ -21,8 +28,10 @@ * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: Avoid NullPointerException if not attribute outs are present. -2012-10-03 Felix Wolfsteller +2012-10-04 Felix Wolfsteller + Fix issue417. + * flys-artifacts/doc/conf/default-themes, flys-artifacts/doc/conf/second-themes, flys-artifacts/doc/conf/virtual-themes: diff -r 4bc58d6ee9db -r e4e345d81a65 flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Thu Oct 04 14:12:03 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Thu Oct 04 14:54:44 2012 +0200 @@ -265,9 +265,19 @@ public static double getWAtKmLin(WKms wkms, double km) { // Uninformed search. int size = wkms.size(); + if (size == 0) { + return -1; + } int idx = 0; - boolean kmIncreasing = (wkms.getKm(0) < wkms.getKm(wkms.size()-1)) - ? true : false; + + boolean kmIncreasing; + if (size == 1) { + kmIncreasing = true; + } + else { + kmIncreasing = (wkms.getKm(0) < wkms.getKm(wkms.size()-1)) + ? true : false; + } if (kmIncreasing) { while (idx < size && wkms.getKm(idx) < km) { idx++; @@ -280,6 +290,10 @@ } } + if (wkms.getKm(idx) == km) { + return wkms.getW(idx); + } + if (idx == size -1 || idx == 0) { return -1; }