diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java @ 8950:b0aeed4c97c1

Implemented chart output for sinfo flow depth min/max calculation
author gernotbelger
date Thu, 15 Mar 2018 17:22:28 +0100
parents a4f1ac81f26d
children ee5ce13016ed
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java	Wed Mar 14 18:34:34 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java	Thu Mar 15 17:22:28 2018 +0100
@@ -18,7 +18,7 @@
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
 
-public final class FlowDepthProcessor extends AbstractSInfoLineProcessor<AbstractTkhCalculationResult> {
+public final class FlowDepthProcessor extends AbstractSInfoLineProcessor<AbstractSInfoCalculationResult> {
 
     private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label";
 
@@ -35,11 +35,21 @@
 
     private static final String I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_with_tkh.filtered.description";
 
+    public static final String FACET_FLOW_DEPTH_MIN_FILTERED = "sinfo_facet_flow_depth_min.filtered";
+
+    private static final String I18N_FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_min.filtered.description";
+
+    public static final String FACET_FLOW_DEPTH_MAX_FILTERED = "sinfo_facet_flow_depth_max.filtered";
+
+    private static final String I18N_FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_max.filtered.description";
+
     private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
 
     static {
         HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_FILTERED);
         HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_TKH_FILTERED);
+        HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_MIN_FILTERED);
+        HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_MAX_FILTERED);
     }
 
     public FlowDepthProcessor() {
@@ -47,7 +57,7 @@
     }
 
     @Override
-    protected double[][] doGetPoints(final AbstractTkhCalculationResult data, final String facetName) {
+    protected double[][] doGetPoints(final AbstractSInfoCalculationResult data, final String facetName) {
 
         if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName))
             return data.getStationPoints(SInfoResultType.flowdepth);
@@ -55,6 +65,12 @@
         if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName))
             return data.getStationPoints(SInfoResultType.flowdepthtkh);
 
+        if (FACET_FLOW_DEPTH_MIN_FILTERED.contentEquals(facetName))
+            return data.getStationPoints(SInfoResultType.flowdepthmin);
+
+        if (FACET_FLOW_DEPTH_MAX_FILTERED.contentEquals(facetName))
+            return data.getStationPoints(SInfoResultType.flowdepthmax);
+
         final String error = String.format("Unknown facet name: %s", facetName);
         throw new UnsupportedOperationException(error);
     }
@@ -74,4 +90,22 @@
         return new SInfoResultFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_TKH_FILTERED, facetFlowDepthTkhFilteredDescription,
                 SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
     }
+
+    public static Facet createFlowDepthMinFacet(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_MIN_FILTERED_DESCRIPTION,
+                I18N_FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION, result.getLabel());
+        return new SInfoResultFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_MIN_FILTERED, facetFlowDepthFilteredDescription,
+                SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
+    }
+
+    public static Facet createFlowDepthMaxFacet(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_MAX_FILTERED_DESCRIPTION,
+                I18N_FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION, result.getLabel());
+        return new SInfoResultFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_MAX_FILTERED, facetFlowDepthFilteredDescription,
+                SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
+    }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org