view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9190:0633f963c5be

uinfo.inundationduration workflow
author gernotbelger
date Thu, 28 Jun 2018 15:10:04 +0200
parents dace17e26d33
children 787fc085459b
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.inundationduration;

import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;

/**
 * Access to the flow depth calculation type specific SInfo artifact data.
 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
 * reference to the artifact instance.
 * Hence we do NOT cache any data.
 *
 * @author Gernot Belger
 */
final class InundationDurationAccess extends RangeAccess {

    // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR
    public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
    public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";

    private final EpochYearAccessHelper helper;

    // Fields from state:
    //
    // calculation_mode (String)
    // ld_from, ld_to
    // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year)
    // singleyear (String)
    // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier))
    // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe)
    // sedimentheight String
    //
    // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen

    public InundationDurationAccess(final UINFOArtifact uinfo) {
        super(uinfo);
        /* assert calculation mode */
        final UinfoCalcMode calculationMode = uinfo.getCalculationMode();
        this.helper = new EpochYearAccessHelper(uinfo);
        assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration);
    }

    public Integer getYear() {
        final int[] years = this.helper.getYears("state.uinfo.year", "singleyear");
        if (years != null) {
            return years[0];
        }
        return null;
    }

    public String getWMSUrl() {

        final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName());
        if (this.getYear() != null) {
            return helper.urlFromYear(this.getYear());
        } else {
            return helper.getMittelUrl(); // nur 2 cases...
        }

    }

    public String getWMSScenarioUrl() {
        if (getIsUseScenario()) {
            final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName());
            if (this.getYear() != null) {
                return helper.getScenarioUrlFromYear(this.getYear(), this.getDwspl());
            } else {
                return helper.getMittelScenarioUrl(this.getDwspl()); // nur 2 cases...
            }
        }
        return "";
    }

    public Integer getDwspl() {
        if (getIsUseScenario()) {
            return super.getInteger("sedimentheight");
        }
        return null;
    }

    public String getVegZones() {
        // mit VegetationzonesAccess zusammenlegen (eine Zeile sparen...)
        return super.getString("vegzones");
    }

    public boolean getIsUseScenario() {
        return super.getBoolean("use_scenario");
    }

    public Integer[] mittelStartEndYears() {
        if (getIsUseScenario()) {
            final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName());
            return helper.getMittelStartEnd();
        }
        return null;
    }
}

http://dive4elements.wald.intevation.org