diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentProcessor.java @ 8956:ee5ce13016ed

Work on SINFO-Fließtiefenentwicklung
author gernotbelger
date Tue, 20 Mar 2018 13:30:07 +0100
parents
children b194fa64506a
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/common/FlowDepthDevelopmentProcessor.java	Tue Mar 20 13:30:07 2018 +0100
@@ -0,0 +1,94 @@
+/* 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.common;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+
+public final class FlowDepthDevelopmentProcessor extends AbstractSInfoLineProcessor<AbstractSInfoCalculationResult> {
+
+    private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development.section.yaxis.label";
+
+    private static final String SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL = "sinfo.chart.flow_depth.yaxis.label";
+
+    /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */
+    // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data
+    // changes depending on zoom state
+    public static final String FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED = "sinfo_facet_flow_depth_development.filtered";
+
+    private static final String I18N_FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_development.filtered.description";
+
+    public static final String FACET_WATERLEVEL_DIFFERENCE_FILTERED = "sinfo_facet_waterlevel_difference.filtered";
+
+    private static final String I18N_FACET_WATERLEVEL_DIFFERENCE_FILTERED_DESCRIPTION = "sinfo.facet.waterlevel_difference.filtered.description";
+
+    public static final String FACET_BEDHEIGHT_DIFFERENCE_FILTERED = "sinfo_facet_bedheight_difference.filtered";
+
+    private static final String I18N_FACET_BEDHEIGHT_DIFFERENCE_FILTERED_DESCRIPTION = "sinfo.facet.bedheight_difference.filtered.description";
+
+    private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
+
+    static {
+        HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED);
+        HANDLED_FACET_TYPES.add(FACET_WATERLEVEL_DIFFERENCE_FILTERED);
+        HANDLED_FACET_TYPES.add(FACET_BEDHEIGHT_DIFFERENCE_FILTERED);
+    }
+
+    public FlowDepthDevelopmentProcessor() {
+        super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
+    }
+
+    @Override
+    protected double[][] doGetPoints(final AbstractSInfoCalculationResult data, final String facetName) {
+
+        if (FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED.contentEquals(facetName))
+            return data.getStationPoints(SInfoResultType.flowdepthDevelopment);
+
+        if (FACET_WATERLEVEL_DIFFERENCE_FILTERED.contentEquals(facetName))
+            return data.getStationPoints(SInfoResultType.waterlevelDifference);
+
+        if (FACET_BEDHEIGHT_DIFFERENCE_FILTERED.contentEquals(facetName))
+            return data.getStationPoints(SInfoResultType.bedHeightDifference);
+
+        final String error = String.format("Unknown facet name: %s", facetName);
+        throw new UnsupportedOperationException(error);
+    }
+
+    public static Facet createFlowDepthDevelopmentFacet(final CallContext context, final String hash, final String id,
+            final AbstractSInfoCalculationResult result, final int index) {
+        final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION,
+                I18N_FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION, result.getLabel());
+        return new SInfoResultFacet(index, FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED, facetFlowDepthFilteredDescription,
+                SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
+    }
+
+    public static Facet createWaterlevelDifferenceFacet(final CallContext context, final String hash, final String id,
+            final AbstractSInfoCalculationResult result, final int index) {
+        final String facetFlowDepthTkhFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_WATERLEVEL_DIFFERENCE_FILTERED_DESCRIPTION,
+                I18N_FACET_WATERLEVEL_DIFFERENCE_FILTERED_DESCRIPTION, result.getLabel());
+        return new SInfoResultFacet(index, FACET_WATERLEVEL_DIFFERENCE_FILTERED, facetFlowDepthTkhFilteredDescription,
+                SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
+    }
+
+    public static Facet createBedHeightDifferenceFacet(final CallContext context, final String hash, final String id,
+            final AbstractSInfoCalculationResult result, final int index) {
+
+        final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_BEDHEIGHT_DIFFERENCE_FILTERED_DESCRIPTION,
+                I18N_FACET_BEDHEIGHT_DIFFERENCE_FILTERED_DESCRIPTION, result.getLabel());
+        return new SInfoResultFacet(index, FACET_BEDHEIGHT_DIFFERENCE_FILTERED, facetFlowDepthFilteredDescription,
+                SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org