view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation5.java @ 2276:2966787b5188

Added service for discharge infos at a specific gauge. flys-artifacts/trunk@3935 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 06 Feb 2012 15:37:54 +0000
parents 3973a2451cf7
children d4330439be3a
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import java.util.ArrayList;
import java.util.Map;

import org.apache.log4j.Logger;


public class Calculation5
extends      Calculation
{
    private static Logger log = Logger.getLogger(Calculation5.class);

    protected double    startKm;
    protected double [] endKms;

    public Calculation5() {
    }

    public Calculation5(double startKm, double [] endKms) {
        this.startKm = startKm;
        this.endKms  = endKms;
    }

    public CalculationResult calculate(
        WstValueTable       wst, 
        Map<Double, Double> kms2gaugeDatums
    ) {
        ArrayList<WW> results = new ArrayList<WW>();

        int numProblems = numProblems();

        for (double endKm: endKms) {

            double [][] wws = wst.relateWs(startKm, endKm, this);
            int newNumProblems = numProblems();

            if (wws.length == 4) {
                WWQQ wwqq = new WWQQ(
                    generateName(startKm, endKm),
                    startKm, kms2gaugeDatums.get(startKm), wws[0], wws[1],
                    endKm,   kms2gaugeDatums.get(endKm),   wws[2], wws[3]);

                if (newNumProblems > numProblems) {
                    wwqq.removeNaNs();
                }

                results.add(wwqq);
            }
            numProblems = newNumProblems;
        }

        return new CalculationResult(
            results.toArray(new WW[results.size()]),
            this);
    }

    protected static String generateName(double startKm, double endKm) {
        // TODO: I18N
        return "W(km " + startKm + ") ~ W(km " + endKm + ")";
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org