Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java @ 1678:03fbf1b30e72
Removed code duplication of guessWaterIncreasing()
flys-artifacts/trunk@2895 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 05 Oct 2011 13:16:44 +0000 |
parents | 821aaceb2776 |
children | bda04ae1154f |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java Wed Oct 05 11:23:18 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java Wed Oct 05 13:16:44 2011 +0000 @@ -1,9 +1,9 @@ package de.intevation.flys.artifacts.model; +import de.intevation.flys.utils.DataUtil; + import gnu.trove.TDoubleArrayList; -import java.util.Random; - import org.apache.log4j.Logger; public class WQ @@ -117,26 +117,7 @@ } public boolean guessWaterIncreasing(float factor) { - - int N = w.size(); - if (N < 2) return false; - - int samples = (int)(factor*N) + 1; - - int up = 0; - - Random rand = new Random(); - - 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); - if (w2 > w1) ++up; - } - - return up > samples/2; + return DataUtil.guessWaterIncreasing(w, factor); } public int [] longestIncreasingWRangeIndices() {