view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCrossSectionIndexData.java @ 9430:e8b1255fc89e

Added calculation of salix hw5 and salix line w
author mschaefer
date Mon, 20 Aug 2018 09:41:07 +0200
parents bd5f5d2220fa
children ee6508687e3f
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
 * Software engineering by
 *  Björnsen Beratende Ingenieure GmbH
 *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
 *
 * 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.uinfo.salix;

import java.io.Serializable;

import org.dive4elements.artifacts.CallContext;

/**
 * The 'index' that tells the cross section facet which of my result are to be fetched as a cross section line.
 *
 * @author Gernot Belger
 */
public final class SalixLineCrossSectionIndexData implements Serializable {

    /**
     * Known waterlevels of the salix computation
     */
    public enum SalixWaterlevel {
        mnw, mw, mhw, hw5
    }

    private static final long serialVersionUID = 1L;

    private static final SalixLineCrossSectionIndexData SALIX_LINE = new SalixLineCrossSectionIndexData(null, null);

    // REMARK: we know at the moment there is exactly one result
    private final int resultIndex = 0;

    private final Integer scenarioIndex;

    private final SalixWaterlevel waterlevel;

    /**
     * Creates an instance of this class that represants the salix line.
     */
    public static final SalixLineCrossSectionIndexData salixLine() {
        return SALIX_LINE;
    }

    /**
     * Creates an instance of this class that represants the salix line.
     */
    public static final SalixLineCrossSectionIndexData scenario(final int scenarioIndex) {
        return new SalixLineCrossSectionIndexData(scenarioIndex, null);
    }

    /**
     * Creates an instance of this class that represants the salix line.
     */
    // FIXME: gemeint sind die einzublendenden 'MNW, MW, MHW, HW5' mir nicht klar wo diese Daten herkommen, ggf. aus der
    // Rechnung?
    // FIXME: statt 'name' vielleicht eine enum oder irgend etwas anderes was diese dinger eindeutig referenzieet?
    public static final SalixLineCrossSectionIndexData waterlevel(final SalixWaterlevel name) {
        assert name != null;
        return new SalixLineCrossSectionIndexData(null, name);
    }

    private SalixLineCrossSectionIndexData(final Integer scenarioIndex, final SalixWaterlevel waterlevel) {
        this.scenarioIndex = scenarioIndex;
        this.waterlevel = waterlevel;
    }

    public double getCrossSectionLine(final SalixLineCalculationResults results, final double currentKm, final double nextKm, final double prevKm,
            final CallContext context) {

        final SalixLineCalculationResult result = results.getResults().get(this.resultIndex);

        if (this.scenarioIndex != null) {
            // fetch scenario result data = salix line value at km
            return result.getSalixScenarioValue(currentKm, nextKm, prevKm, this.scenarioIndex);
        }

        if (this.waterlevel != null) {
            // fetch waterlevel result data = salix line value at km
            return result.getWaterlevelValue(currentKm, nextKm, prevKm, this.waterlevel);
        }

        // fetch normal result data = salix line value at km
        return result.getSalixValue(currentKm, nextKm, prevKm);
    }
}

http://dive4elements.wald.intevation.org