view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 2719:d1d35892bbdd

Adjusted fixings transitions and implemented event select state. flys-artifacts/trunk@4450 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 21 May 2012 09:27:32 +0000
parents 6ed24efc80de
children a441be7f1589
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import de.intevation.flys.artifacts.math.Linear;

import java.util.Arrays;

import java.io.Serializable;

public class FixingsColumn
implements   Serializable
{
    protected double [] kms;
    protected double [] ws;

    protected QRangeTree qs;

    public FixingsColumn() {
    }

    public FixingsColumn(
        double []  kms,
        double []  ws,
        QRangeTree qs
    ) {
        this.kms = kms;
        this.ws  = ws;
        this.qs  = qs;
    }

    public boolean getW(double km, double [] w) {

        if (kms.length == 0 || km < kms[0] || km > kms[kms.length-1]) {
            w[0] = Double.NaN;
            return true;
        }

        int idx = Arrays.binarySearch(kms, km);

        if (idx >= 0) {
            w[0] = ws[idx];
            return true;
        }

        idx = -idx - 1;

        w[0] = Linear.linear(km, kms[idx], kms[idx+1], ws[idx], ws[idx+1]);
        return false;
    }

    public double getQ(double km) {
        return qs.findQ(km);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org