view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQCKms.java @ 636:58276db49b16

Generate fields for w/q input depend on flow direction. flys-artifacts/trunk@2012 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 May 2011 15:55:48 +0000
parents eb22ffe4d74c
children 913b52064449
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import gnu.trove.TDoubleArrayList;


/**
 * This class represents a pool of data triples that consists of 'W', 'Q' and
 * 'KM' data with corrected 'W' values computed by a BackJumpCorrector.
 *
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class WQCKms extends WQKms {

    protected TDoubleArrayList cw;


    public WQCKms(double[] kms, double[] qs, double[] ws, double[] cws) {
        super(kms, qs, ws);

        this.cw = new TDoubleArrayList(cws);
    }


    /**
     * Adds a new row to this data pool with corrected W.
     *
     * @param w a W.
     * @param q a Q.
     * @param kms a Kms.
     * @param cw The corrected W.
     */
    public void add(double w, double q, double kms, double cw) {
        add(w, q, kms);
        this.cw.add(cw);
    }


    /**
     * This method returns a 4dim array of W, Q,Kms and corrected W.
     *
     * @param idx The position of the triple.
     * @param dst destination array
     *
     * @return a 4dim array of [W, Q, Kms, CW] in dst.
     */
    public double[] get(int idx, double[] dst) {
        dst = super.get(idx, dst);

        if (dst.length < 4) {
            return dst;
        }

        if (cw != null && cw.size() > idx) {
            dst[3] = cw.get(idx);
        }

        return dst;
    }


    /**
     * Returns the double array of corrected W values.
     *
     * @return the double array of corrected W values.
     */
    public double[] getCWs() {
        return cw.toNativeArray();
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org