view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQCKms.java @ 1710:055f32a5388a

Improved the mapfile templates to create nicer GetLegendGraphic images. flys-artifacts/trunk@2970 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 14 Oct 2011 11:13:04 +0000
parents 035c0095b427
children 5ff481ab24a1
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);
    }

    @Override
    public void removeNaNs() {
        removeNaNs(new TDoubleArrayList [] { w, q, cw, kms });
    }


    /**
     * 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.
     */
    @Override
    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.getQuick(idx);
        }

        return dst;
    }

    public double getC(int idx) {
        return cw.getQuick(idx);
    }


    /**
     * 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