view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeCurveFacet.java @ 3937:c254939fae52

Also add the name to the artifact description flys-artifacts/trunk@5637 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 28 Sep 2012 08:46:21 +0000
parents 4e1b3b4ef132
children a4930c43b806
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import java.util.Arrays;
import java.util.Map;

import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallContext;
import de.intevation.artifacts.CallMeta;

import de.intevation.artifactdatabase.state.DefaultFacet;
import de.intevation.artifactdatabase.state.Facet;

import de.intevation.flys.artifacts.model.WQKms;

import de.intevation.flys.model.Gauge;

/**
 * A Facet that returns discharge curve data at a gauge
 *
 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
 */
public class GaugeDischargeCurveFacet
extends      DefaultFacet
{
    private Gauge gauge;
    private String river;

    public GaugeDischargeCurveFacet(String river, Gauge gauge) {
        super(0, "facet.gauge.discharge_curve", "facet.gauge.discharge_curve");
        this.river = river;
        this.gauge = gauge;
    }

    @Override
    public Object getData(Artifact art, CallContext context) {

        DischargeTables dt = new DischargeTables(river, gauge.getName());

        Map<String, double [][]> map = dt.getValues(100d);

        double [][] values = map.get(name);
        if (values == null) {
            return null;
        }
        double [] kms = new double[values[0].length];
        Arrays.fill(kms, gauge.getStation().doubleValue());
        return new WQKms(kms, values[0], values[1], gauge.getName());
    }

    @Override
    public Facet deepCopy() {
        GaugeDischargeCurveFacet copy =
            new GaugeDischargeCurveFacet(this.river, this.gauge);
        copy.set(this);
        return copy;
    }
}

http://dive4elements.wald.intevation.org