diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionAccess.java @ 9067:2ed3824a3d53

sinfo access collision, floodDuration
author gernotbelger
date Mon, 14 May 2018 14:59:10 +0200
parents
children 1ffd38826175
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionAccess.java	Mon May 14 14:59:10 2018 +0200
@@ -0,0 +1,62 @@
+/* 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");
+    }
+
+    public int[][] getEpochs() {
+        return this.helper.getEpochs("state.sinfo.epoch");
+    }
+
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org