view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation2.java @ 4241:49cb65d5932d

Improved the historical discharge calculation. The calculation now creates new HistoricalWQKms (new subclass of WQKms). Those WQKms are used to create new facets from (new) type 'HistoricalDischargeCurveFacet'. The chart generator is improved to support those facets.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 24 Oct 2012 14:34:35 +0200
parents c1f445b94d03
children
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import java.util.Arrays;

import org.apache.log4j.Logger;


/** ComputedDischargeCurve. */
public class Calculation2
extends      Calculation
{
    private static Logger logger = Logger.getLogger(Calculation2.class);

    protected double km;

    public Calculation2() {
    }

    public Calculation2(double km) {
        this.km = km;
    }

    public CalculationResult calculate(WstValueTable wst) {

        logger.debug("Calculation2.calculate");

        double [][] wqs = wst.interpolateWQ(km, this);

        if (wqs == null || wqs[0].length == 0) {
            addProblem("cannot.compute.discharge.curve");
            return new CalculationResult(new WQKms[0], this);
        }

        double [] ws = wqs[0];
        double [] qs = wqs[1];
        double [] kms = new double[ws.length];

        Arrays.fill(kms, km);

        WQKms wqkms = new WQKms(kms, qs, ws, String.valueOf(km));

        if (hasProblems()) {
            logger.debug("found " + numProblems() + " problems.");
            wqkms.removeNaNs();
        }

        return new CalculationResult(new WQKms[] { wqkms }, this);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org