view flys-artifacts/src/main/java/de/intevation/flys/utils/DataUtil.java @ 1641:eb3ab28d1c21

The extent of the WSPLGEN facets are now determined by the extent of the start and end CrossSectionTrack of the WSPLGEN calculation. flys-artifacts/trunk@2827 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 26 Sep 2011 15:35:46 +0000
parents 2e0739853807
children 03fbf1b30e72
line wrap: on
line source
package de.intevation.flys.utils;

import java.util.Random;

import de.intevation.flys.artifacts.model.WKms;

public class DataUtil
{
    // TODO: resolve duplicate in WQKms
    public static boolean guessWaterIncreasing(WKms wkms) {
        return guessWaterIncreasing(wkms, 0.05f);
    }

    // TODO: resolve duplicate in WQKms
    public static boolean guessWaterIncreasing(WKms wkms, float factor) {
        int N = wkms.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   = wkms.getW(pos1);
            double w2   = wkms.getW(pos2);
            if (w2 > w1) ++up;
        }
    
        return up > samples/2;
    }
}

http://dive4elements.wald.intevation.org