comparison 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
comparison
equal deleted inserted replaced
8955:798d9dcbccdd 8956:ee5ce13016ed
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 FlowDepthDevelopmentProcessor extends AbstractSInfoLineProcessor<AbstractSInfoCalculationResult> {
22
23 private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development.section.yaxis.label";
24
25 private static final String SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_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_DEVELOPMENT_FILTERED = "sinfo_facet_flow_depth_development.filtered";
31
32 private static final String I18N_FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_development.filtered.description";
33
34 public static final String FACET_WATERLEVEL_DIFFERENCE_FILTERED = "sinfo_facet_waterlevel_difference.filtered";
35
36 private static final String I18N_FACET_WATERLEVEL_DIFFERENCE_FILTERED_DESCRIPTION = "sinfo.facet.waterlevel_difference.filtered.description";
37
38 public static final String FACET_BEDHEIGHT_DIFFERENCE_FILTERED = "sinfo_facet_bedheight_difference.filtered";
39
40 private static final String I18N_FACET_BEDHEIGHT_DIFFERENCE_FILTERED_DESCRIPTION = "sinfo.facet.bedheight_difference.filtered.description";
41
42 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
43
44 static {
45 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED);
46 HANDLED_FACET_TYPES.add(FACET_WATERLEVEL_DIFFERENCE_FILTERED);
47 HANDLED_FACET_TYPES.add(FACET_BEDHEIGHT_DIFFERENCE_FILTERED);
48 }
49
50 public FlowDepthDevelopmentProcessor() {
51 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
52 }
53
54 @Override
55 protected double[][] doGetPoints(final AbstractSInfoCalculationResult data, final String facetName) {
56
57 if (FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED.contentEquals(facetName))
58 return data.getStationPoints(SInfoResultType.flowdepthDevelopment);
59
60 if (FACET_WATERLEVEL_DIFFERENCE_FILTERED.contentEquals(facetName))
61 return data.getStationPoints(SInfoResultType.waterlevelDifference);
62
63 if (FACET_BEDHEIGHT_DIFFERENCE_FILTERED.contentEquals(facetName))
64 return data.getStationPoints(SInfoResultType.bedHeightDifference);
65
66 final String error = String.format("Unknown facet name: %s", facetName);
67 throw new UnsupportedOperationException(error);
68 }
69
70 public static Facet createFlowDepthDevelopmentFacet(final CallContext context, final String hash, final String id,
71 final AbstractSInfoCalculationResult result, final int index) {
72 final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION,
73 I18N_FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION, result.getLabel());
74 return new SInfoResultFacet(index, FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED, facetFlowDepthFilteredDescription,
75 SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
76 }
77
78 public static Facet createWaterlevelDifferenceFacet(final CallContext context, final String hash, final String id,
79 final AbstractSInfoCalculationResult result, final int index) {
80 final String facetFlowDepthTkhFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_WATERLEVEL_DIFFERENCE_FILTERED_DESCRIPTION,
81 I18N_FACET_WATERLEVEL_DIFFERENCE_FILTERED_DESCRIPTION, result.getLabel());
82 return new SInfoResultFacet(index, FACET_WATERLEVEL_DIFFERENCE_FILTERED, facetFlowDepthTkhFilteredDescription,
83 SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
84 }
85
86 public static Facet createBedHeightDifferenceFacet(final CallContext context, final String hash, final String id,
87 final AbstractSInfoCalculationResult result, final int index) {
88
89 final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_BEDHEIGHT_DIFFERENCE_FILTERED_DESCRIPTION,
90 I18N_FACET_BEDHEIGHT_DIFFERENCE_FILTERED_DESCRIPTION, result.getLabel());
91 return new SInfoResultFacet(index, FACET_BEDHEIGHT_DIFFERENCE_FILTERED, facetFlowDepthFilteredDescription,
92 SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
93 }
94 }

http://dive4elements.wald.intevation.org