comparison 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
comparison
equal deleted inserted replaced
925:0cb1a70b8b92 926:659608128823
113 } 113 }
114 114
115 public boolean guessWaterIncreasing(float factor) { 115 public boolean guessWaterIncreasing(float factor) {
116 116
117 int N = w.size(); 117 int N = w.size();
118 if (N < 2) return false;
119
118 int samples = (int)(factor*N) + 1; 120 int samples = (int)(factor*N) + 1;
119 121
120 int up = 0; 122 int up = 0;
121 123
122 Random rand = new Random(); 124 Random rand = new Random();
123 125
124 for (int i = 0; i < samples; ++i) { 126 for (int i = 0; i < samples; ++i) {
125 int pos2 = rand.nextInt(N-1) + 1; 127 int pos2 = rand.nextInt(N-1) + 1;
128 if (pos2 == 0) continue;
126 int pos1 = rand.nextInt(pos2); 129 int pos1 = rand.nextInt(pos2);
127 double w1 = w.getQuick(pos1); 130 double w1 = w.getQuick(pos1);
128 double w2 = w.getQuick(pos2); 131 double w2 = w.getQuick(pos2);
129 if (w2 > w1) ++up; 132 if (w2 > w1) ++up;
130 } 133 }

http://dive4elements.wald.intevation.org