changeset 926:659608128823

Fix(?) for flys/issue114 flys-artifacts/trunk@2280 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 04 Jul 2011 13:23:54 +0000 (2011-07-04)
parents 0cb1a70b8b92
children 53a2be494765
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sun Jul 03 15:33:33 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jul 04 13:23:54 2011 +0000
@@ -1,3 +1,10 @@
+2011-07-04  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	Fix(?) for flys/issue114
+
+	* src/main/java/de/intevation/flys/artifacts/model/WQ.java:
+	  Make guessing a bit more robust.
+
 2011-07-03  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	Added the math needed to calculate "W-Differenzen" in "Laengsschnitten".
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java	Sun Jul 03 15:33:33 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java	Mon Jul 04 13:23:54 2011 +0000
@@ -115,6 +115,8 @@
     public boolean guessWaterIncreasing(float factor) {
 
         int N = w.size();
+        if (N < 2) return false;
+
         int samples = (int)(factor*N) + 1;
 
         int up = 0;
@@ -123,6 +125,7 @@
 
         for (int i = 0; i < samples; ++i) {
             int    pos2 = rand.nextInt(N-1) + 1;
+            if (pos2 == 0) continue;
             int    pos1 = rand.nextInt(pos2);
             double w1   = w.getQuick(pos1);
             double w2   = w.getQuick(pos2);

http://dive4elements.wald.intevation.org