Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java @ 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 |
parents | 0cb1a70b8b92 |
children | 821aaceb2776 |
line wrap: on
line diff
--- 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);