ingo@361: package de.intevation.flys.artifacts.model; ingo@361: ingo@365: import gnu.trove.TDoubleArrayList; ingo@361: ingo@402: import org.apache.log4j.Logger; ingo@402: ingo@361: ingo@361: /** ingo@361: * This class represents a pool of data triples that consists of 'W', 'Q' and ingo@361: * 'KM' data. ingo@361: * ingo@361: * @author Ingo Weinzierl ingo@361: */ sascha@742: public class WQKms sascha@726: extends WQ sascha@726: { ingo@402: private static Logger logger = Logger.getLogger(WQKms.class); ingo@402: ingo@361: /** The array that contains the 'KMs' values.*/ ingo@365: protected TDoubleArrayList kms; ingo@361: ingo@361: ingo@361: public WQKms() { ingo@447: this(""); ingo@447: } ingo@447: ingo@447: ingo@447: public WQKms(String name) { ingo@447: super(name); ingo@365: this.kms = new TDoubleArrayList(); ingo@361: } ingo@361: ingo@447: sascha@380: public WQKms(int capacity) { ingo@447: this(capacity, ""); ingo@447: } ingo@447: ingo@447: ingo@447: public WQKms(int capacity, String name) { ingo@447: super(name); sascha@380: this.kms = new TDoubleArrayList(capacity); sascha@380: } sascha@380: sascha@726: public WQKms(double [] kms, double [] qs, double [] ws) { ingo@447: this(kms, qs, ws, ""); ingo@447: } ingo@447: ingo@447: sascha@726: public WQKms(double [] kms, double [] qs, double [] ws, String name) { sascha@726: super(qs, ws, name); ingo@402: this.kms = new TDoubleArrayList(kms); ingo@402: } ingo@402: sascha@726: @Override sascha@726: public void removeNaNs() { sascha@726: removeNaNs(new TDoubleArrayList [] { w, q, kms }); sascha@726: } ingo@402: ingo@361: /** ingo@361: * Adds a new row to this data pool. ingo@361: * ingo@361: * @param w a W. ingo@361: * @param q a Q. ingo@361: * @param kms a Kms. ingo@361: */ sascha@726: public void add(double w, double q, double km) { sascha@726: super.add(w, q); sascha@726: kms.add(km); sascha@366: } sascha@366: sascha@366: /** sascha@366: * This method returns a triple of W, Q and Kms in a single 3dim array. sascha@366: * sascha@366: * @param idx The position of the triple. sascha@366: * @param dst destination array sascha@366: * sascha@366: * @return a triple of [W, Q, Kms] in dst. sascha@366: */ sascha@726: @Override sascha@366: public double[] get(int idx, double [] dst) { ingo@686: dst[0] = w .getQuick(idx); ingo@686: dst[1] = q .getQuick(idx); ingo@686: dst[2] = kms.getQuick(idx); sascha@366: return dst; ingo@361: } ingo@367: ingo@367: public double getKms(int idx) { ingo@686: return kms.getQuick(idx); ingo@367: } ingo@402: ingo@402: public double[] getKms() { ingo@402: return kms.toNativeArray(); ingo@402: } ingo@402: ingo@402: /** ingo@402: * Returns a string that consist of the first and last kilometer. ingo@402: * ingo@402: * @return a string that consist of the first and last kilometer. ingo@402: */ ingo@402: public String toString() { ingo@402: double from = getKms(0); ingo@402: double to = getKms(size()-1); ingo@686: return from + " - " + to; ingo@402: } ingo@361: } ingo@361: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :