view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQCKms.java @ 655:913b52064449

Refactored version of "Berechnung 4" flys-artifacts/trunk@2053 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 05 Jun 2011 18:24:46 +0000
parents eb22ffe4d74c
children 8b0152363bdb 3dc61e00385e
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() {
    }

    public WQCKms(WQKms other, double [] cws) {
        this.w   = other.w;
        this.q   = other.q;
        this.kms = other.kms;
        this.cw  = new TDoubleArrayList(cws);
    }


    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