view artifacts/src/main/java/org/dive4elements/river/artifacts/AbstractFixBunduArtifact.java @ 9486:ce13a2f07290

pdf exports added for fixation+bundu (waterlevel)
author gernotbelger
date Mon, 17 Sep 2018 19:07:57 +0200
parents da7b5f07303d
children
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */

package org.dive4elements.river.artifacts;

import java.io.Serializable;

import org.apache.log4j.Logger;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.model.CalculationResult;
import org.dive4elements.river.artifacts.model.WKms;
import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;

/**
 * The default fixation analysis artifact.
 *
 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
 */
public class AbstractFixBunduArtifact extends D4EArtifact implements WaterLineArtifact {

    private static final long serialVersionUID = 1L;

    /** The log for this class. */
    private static Logger log = Logger.getLogger(AbstractFixBunduArtifact.class);

    /**
     * The default constructor.
     */
    public AbstractFixBunduArtifact() {
        log.debug("ctor()");
    }

    /** Calculate waterlines against a cross section. */
    @Override
    public double getWaterLevel(final ComputeType type, final String hash, final String stateId, final double currentKm, final Serializable waterLineIndex,
            final double nextKm, final double prevKm, final CallContext context) {
        final FixRealizingResult result = (FixRealizingResult) ((CalculationResult) this.compute(context, ComputeType.ADVANCE, false)).getData();

        final int wstIndex = (Integer) waterLineIndex;

        final WKms wkms = result.getWQKms()[wstIndex];

        // Find W at km.
        final double wAtKm = StaticWKmsArtifact.getWAtKm(wkms, currentKm);

        if (wAtKm == -1 || Double.isNaN(wAtKm)) {
            log.warn("Waterlevel at km " + currentKm + " unknown.");
            return Double.NaN;
        }

        return wAtKm;
    }

    public String getCalculationModeString() {
        return null; // must be implemented in inheriting classes. cannot declare this class abstract
    }

}

http://dive4elements.wald.intevation.org