view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionAccess.java @ 9069:1ffd38826175

access uinfo.vegetationzones+inundation_duration
author gernotbelger
date Tue, 15 May 2018 12:00:26 +0200
parents 2ed3824a3d53
children 611a523fc42f
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.sinfo.collision;

import org.apache.commons.lang.math.DoubleRange;
import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.common.AccessHelper;
import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;

/**
 * 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 CollisionAccess extends RangeAccess {

    private final AccessHelper helper;

    /// Fields from state:

    // calculation_mode (String), sollte sinfo_calc_collision sein
    // ld_from, ld_to
    // ye_select (String), mögliche werte: "state.sinfo.epoch" "state.sinfo.year"
    // years (String)
    // epochs (String)

    public CollisionAccess(final SINFOArtifact artifact) {
        super(artifact);

        /* assert calculation mode */
        final SinfoCalcMode calculationMode = artifact.getCalculationMode();
        this.helper = new AccessHelper(artifact);
        assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth);
    }

    public DoubleRange getRange() {
        final double from = getFrom();
        final double to = getTo();
        return new DoubleRange(from, to);
    }

    public int[] getYears() {
        return this.helper.getYears("state.sinfo.year", "years");
    }

    public int[][] getEpochs() {
        return this.helper.getEpochs("state.sinfo.epoch", "epochs");
    }

}

http://dive4elements.wald.intevation.org