view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9178:2f5052835b76

uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
author gernotbelger
date Tue, 26 Jun 2018 19:48:35 +0200
parents 9b4f5e61c02e
children dace17e26d33
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 Double getSedimentHeight() {
        if (super.getBoolean("use_scenario")) {
            return super.getDouble("sedimentheight"); // TODO: INPUT Valdiation (nicht hier, sondern im Panel. Erinnerung)
        }
        return null;
    }

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

    // TODO: eigentlich nur die WMS-Url des gewählten dingens (jahr, oder epoche)
    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 getVegZones() {
        // MIT VegetationzonesAccess zusammenlegen (eine Zeile sparen...)
        return super.getString("vegzones");
    }

}

http://dive4elements.wald.intevation.org