Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstDepthProcessor.java @ 9592:e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
author | gernotbelger |
---|---|
date | Fri, 11 Jan 2019 16:58:44 +0100 |
parents | 3fa8551c3d1b |
children | 5395c6d4ca50 |
rev | line source |
---|---|
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
2 * Software engineering by |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
5 * |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
9 */ |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
10 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
11 package org.dive4elements.river.artifacts.bundu.bezugswst; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
12 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
13 import java.util.HashSet; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
14 import java.util.Set; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
15 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
17 import org.dive4elements.artifactdatabase.state.Facet; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
18 import org.dive4elements.artifacts.CallContext; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
19 import org.dive4elements.river.artifacts.bundu.BunduResultType; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
20 import org.dive4elements.river.artifacts.common.AbstractProcessor; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
21 import org.dive4elements.river.artifacts.common.AbstractResultType; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
22 import org.dive4elements.river.artifacts.resources.Resources; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
23 import org.dive4elements.river.exports.DiagramGenerator; |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
24 import org.dive4elements.river.model.BedHeightValueType; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
25 import org.dive4elements.river.themes.ThemeDocument; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
26 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
27 /** |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
28 * Processor to generate the facets and data series of a bundu bezugswst depth longitudinal section |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
29 * |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
30 * @author Matthias Schäfer |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
31 * |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
32 */ |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
33 public final class BezugswstDepthProcessor extends AbstractProcessor { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
34 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
35 private static final String FACET_FLOWDEPTH_FILTERED = "bundu_facet_flowdepth.filtered"; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
36 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
37 private static final String FACET_FLOWDEPTH_FILTERED_DESCRIPTION = "bundu_facet_flowdepth.filtered.description"; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
38 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
39 public static final String FACET_CHANNELDEPTH = "bundu_facet_channeldepth"; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
40 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
41 private static final String FACET_CHANNELDEPTH_DESCRIPTION = "bundu_facet_channeldepth.description"; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
42 |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
43 public static final String FACET_FIELD_DEPTH_PREFIX = "bundu_facet_depth_"; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
44 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
45 private static final String FACET_FIELD_DEPTH_FORMAT = FACET_FIELD_DEPTH_PREFIX + "%02d.filtered"; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
46 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
47 private static final String FACET_FIELD_DEPTH_DESCRIPTION = "bundu_facet_field_depth.description"; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
48 |
9592
e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
gernotbelger
parents:
9535
diff
changeset
|
49 private static final String AXIS_LABEL = "bundu.chart.flow_depth.section.yaxis.label"; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
50 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
51 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
52 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
53 static { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
54 HANDLED_FACET_TYPES.add(FACET_FLOWDEPTH_FILTERED); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
55 HANDLED_FACET_TYPES.add(FACET_CHANNELDEPTH); |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
56 for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++) |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
57 HANDLED_FACET_TYPES.add(String.format(FACET_FIELD_DEPTH_FORMAT, i)); |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
58 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
59 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
60 public BezugswstDepthProcessor() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
61 super(AXIS_LABEL, HANDLED_FACET_TYPES); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
62 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
63 |
9592
e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
gernotbelger
parents:
9535
diff
changeset
|
64 public static Facet createFlowdepthFilteredFacet(final CallContext context, final String hash, final String id, final int facetIndex, final int resultIndex, |
e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
gernotbelger
parents:
9535
diff
changeset
|
65 final String seriesName) { |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
66 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
67 final String description = Resources.getMsg(context.getMeta(), FACET_FLOWDEPTH_FILTERED_DESCRIPTION, FACET_FLOWDEPTH_FILTERED_DESCRIPTION, seriesName); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
68 return new BezugswstResultFacet(facetIndex, resultIndex, FACET_FLOWDEPTH_FILTERED, description, AXIS_LABEL, id, hash); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
69 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
70 |
9592
e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
gernotbelger
parents:
9535
diff
changeset
|
71 public static Facet createChanneldepthFacet(final CallContext context, final String hash, final String id, final int facetIndex, final int resultIndex) { |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
72 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
73 final String description = Resources.getMsg(context.getMeta(), FACET_CHANNELDEPTH_DESCRIPTION, FACET_CHANNELDEPTH_DESCRIPTION); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
74 return new BezugswstResultFacet(facetIndex, resultIndex, FACET_CHANNELDEPTH, description, AXIS_LABEL, id, hash); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
75 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
76 |
9592
e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
gernotbelger
parents:
9535
diff
changeset
|
77 public static Facet createFieldDepthFacet(final CallContext context, final String hash, final String id, final int facetIndex, final int resultIndex, |
e8d8f90308dc
Punkt 11.2 - Fließtiefe bundu und sinfo verschiedene Labels
gernotbelger
parents:
9535
diff
changeset
|
78 final int fieldIndex) { |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
79 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
80 final String description = Resources.getMsg(context.getMeta(), FACET_FIELD_DEPTH_DESCRIPTION, FACET_FIELD_DEPTH_DESCRIPTION, fieldIndex); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
81 final String facetName = String.format(FACET_FIELD_DEPTH_FORMAT, fieldIndex); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
82 return new BezugswstResultFacet(facetIndex, resultIndex, facetName, description, AXIS_LABEL, id, hash); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
83 } |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
84 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
85 @Override |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
86 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
87 |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
88 if (bundle.getFacetName().startsWith(FACET_FIELD_DEPTH_PREFIX)) { |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
89 final int fieldIndex = Integer.parseInt(bundle.getFacetName().substring(FACET_FIELD_DEPTH_PREFIX.length(), FACET_FIELD_DEPTH_PREFIX.length() + 2)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
90 return generateFieldDepthSeries(generator, bundle, theme, visible, fieldIndex); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
91 } |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
92 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
93 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null); |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
94 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
95 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
96 protected AbstractResultType doGetType(final String facetName) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
97 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
98 if (FACET_FLOWDEPTH_FILTERED.contentEquals(facetName)) |
9535
3fa8551c3d1b
Fixed error in bundu bzws missing volume calculation for mean bed height;
mschaefer
parents:
9444
diff
changeset
|
99 return BunduResultType.flowdepthMeanBed; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
100 if (FACET_CHANNELDEPTH.contentEquals(facetName)) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
101 return BunduResultType.channelDepth; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
102 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
103 final String error = String.format("Unknown facet name: %s", facetName); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
104 throw new UnsupportedOperationException(error); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
105 } |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
106 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
107 private final String generateFieldDepthSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
108 final boolean visible, final int fieldIndex) { |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
109 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
110 final BezugswstMainCalculationResult data = (BezugswstMainCalculationResult) getResult(generator, bundle); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
111 final double[][] points = data.getFieldValuePoints(fieldIndex, BunduResultType.depthFields); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
112 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
113 return buildSeriesForPoints(points, generator, bundle, theme, visible, null); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
114 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
diff
changeset
|
115 } |