comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java @ 8940:82998242ba84

Preparing for additional outputs of SINFO-Tkh
author gernotbelger
date Tue, 06 Mar 2018 18:51:18 +0100
parents artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java@5d5d0051723f
children a9950a3a71e5
comparison
equal deleted inserted replaced
8939:2970368ae1e3 8940:82998242ba84
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.artifacts.sinfo.common;
12
13 import java.util.HashSet;
14 import java.util.Set;
15
16 import org.dive4elements.artifactdatabase.state.Facet;
17 import org.dive4elements.artifacts.CallContext;
18 import org.dive4elements.river.artifacts.resources.Resources;
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
20
21 public final class FlowDepthProcessor extends AbstractSInfoLineProcessor {
22
23 private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label";
24
25 private static final String SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL = "sinfo.chart.flow_depth.yaxis.label";
26
27 /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */
28 // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data
29 // changes depending on zoom state
30 public static final String FACET_FLOW_DEPTH_FILTERED = "sinfo_flow_depth.filtered";
31
32 private static final String I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description";
33
34 private static final String FACET_FLOW_DEPTH_TKH_FILTERED = "sinfo_flow_depth.tkh.filtered";
35
36 private static final String I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.tkh.filtered.description";
37
38 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
39
40 static {
41 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_FILTERED);
42 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_TKH_FILTERED);
43 }
44
45 public FlowDepthProcessor() {
46 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
47 }
48
49 @Override
50 protected double[][] doGetPoints(final AbstractSInfoCalculationResult<?> data, final String facetName) {
51
52 if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName))
53 return data.getFlowDepthPoints();
54
55 if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName))
56 return data.getFlowDepthTkhPoints();
57
58 final String error = String.format("Unknown facet name: %s", facetName);
59 throw new UnsupportedOperationException(error);
60 }
61
62 public static Facet createFlowDepthFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult<?> result,
63 final int index) {
64 final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION,
65 I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel());
66 return new SInfoResultFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED, facetFlowDepthFilteredDescription, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL,
67 ComputeType.ADVANCE, id, hash);
68 }
69
70 public static Facet createFlowDepthTkhFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult<?> result,
71 final int index) {
72 final String facetFlowDepthTkhFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION,
73 I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION, result.getLabel());
74 return new SInfoResultFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_TKH_FILTERED, facetFlowDepthTkhFilteredDescription,
75 SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
76 }
77 }

http://dive4elements.wald.intevation.org