comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstHeightProcessor.java @ 9444:ecadc9ed0ba0

Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author mschaefer
date Tue, 21 Aug 2018 13:41:18 +0200
parents d2f5375ede26
children 3fa8551c3d1b
comparison
equal deleted inserted replaced
9443:515643b2c49a 9444:ecadc9ed0ba0
21 import org.dive4elements.river.artifacts.common.AbstractResultType; 21 import org.dive4elements.river.artifacts.common.AbstractResultType;
22 import org.dive4elements.river.artifacts.resources.Resources; 22 import org.dive4elements.river.artifacts.resources.Resources;
23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; 23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
24 import org.dive4elements.river.exports.DiagramGenerator; 24 import org.dive4elements.river.exports.DiagramGenerator;
25 import org.dive4elements.river.exports.LongitudinalSectionGenerator; 25 import org.dive4elements.river.exports.LongitudinalSectionGenerator;
26 import org.dive4elements.river.model.BedHeightValueType;
26 import org.dive4elements.river.themes.ThemeDocument; 27 import org.dive4elements.river.themes.ThemeDocument;
27 28
28 /** 29 /**
29 * Processor to generate the facets and data series of a bundu bezugswst depth longitudinal section 30 * Processor to generate the facets and data series of a bundu bezugswst depth longitudinal section
30 * 31 *
40 41
41 private static final String FACET_BEDHEIGHT = "bundu_facet_bedheight"; 42 private static final String FACET_BEDHEIGHT = "bundu_facet_bedheight";
42 43
43 private static final String FACET_BEDHEIGHT_DESCRIPTION = "bundu_facet_bedheight.description"; 44 private static final String FACET_BEDHEIGHT_DESCRIPTION = "bundu_facet_bedheight.description";
44 45
46 public static final String FACET_FIELD_BEDHEIGHT_PREFIX = "bundu_facet_bedheight_";
47
48 private static final String FACET_FIELD_BEDHEIGHT_FORMAT = FACET_FIELD_BEDHEIGHT_PREFIX + "%02d";
49
50 private static final String FACET_FIELD_BEDHEIGHT_DESCRIPTION = "bundu_facet_field_bedheight.description";
51
45 private static final String AXIS_LABEL = LongitudinalSectionGenerator.I18N_YAXIS_LABEL; 52 private static final String AXIS_LABEL = LongitudinalSectionGenerator.I18N_YAXIS_LABEL;
46 53
47 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); 54 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
48 55
49 static { 56 static {
50 HANDLED_FACET_TYPES.add(FACET_CHANNELMIN); 57 HANDLED_FACET_TYPES.add(FACET_CHANNELMIN);
51 HANDLED_FACET_TYPES.add(FACET_BEDHEIGHT); 58 HANDLED_FACET_TYPES.add(FACET_BEDHEIGHT);
59 for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++)
60 HANDLED_FACET_TYPES.add(String.format(FACET_FIELD_BEDHEIGHT_FORMAT, i));
52 } 61 }
53 62
54 public BezugswstHeightProcessor() { 63 public BezugswstHeightProcessor() {
55 super(AXIS_LABEL, HANDLED_FACET_TYPES); 64 super(AXIS_LABEL, HANDLED_FACET_TYPES);
56 } 65 }
67 76
68 final String description = Resources.getMsg(context.getMeta(), FACET_BEDHEIGHT_DESCRIPTION, FACET_BEDHEIGHT_DESCRIPTION, seriesName); 77 final String description = Resources.getMsg(context.getMeta(), FACET_BEDHEIGHT_DESCRIPTION, FACET_BEDHEIGHT_DESCRIPTION, seriesName);
69 return new BezugswstResultFacet(facetIndex, resultIndex, FACET_BEDHEIGHT, description, AXIS_LABEL, id, hash); 78 return new BezugswstResultFacet(facetIndex, resultIndex, FACET_BEDHEIGHT, description, AXIS_LABEL, id, hash);
70 } 79 }
71 80
81 public static Facet createFieldBedheightFacet(final CallContext context, final String hash, final String id, final int facetIndex,
82 final int resultIndex, final int fieldIndex) {
83
84 final String description = Resources.getMsg(context.getMeta(), FACET_FIELD_BEDHEIGHT_DESCRIPTION, FACET_FIELD_BEDHEIGHT_DESCRIPTION, fieldIndex);
85 final String facetName = String.format(FACET_FIELD_BEDHEIGHT_FORMAT, fieldIndex);
86 return new BezugswstResultFacet(facetIndex, resultIndex, facetName, description, AXIS_LABEL, id, hash);
87 }
88
72 @Override 89 @Override
73 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { 90 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
74 91
75 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE); 92 if (bundle.getFacetName().startsWith(FACET_FIELD_BEDHEIGHT_PREFIX)) {
93 final int fieldIndex = Integer.parseInt(bundle.getFacetName().substring(FACET_FIELD_BEDHEIGHT_PREFIX.length()));
94 return generateFieldHeightSeries(generator, bundle, theme, visible, fieldIndex);
95 }
96
97 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null);
76 } 98 }
77 99
78 protected AbstractResultType doGetType(final String facetName) { 100 protected AbstractResultType doGetType(final String facetName) {
79 101
80 if (FACET_CHANNELMIN.contentEquals(facetName)) 102 if (FACET_CHANNELMIN.contentEquals(facetName))
83 return SInfoResultType.meanBedHeight; 105 return SInfoResultType.meanBedHeight;
84 106
85 final String error = String.format("Unknown facet name: %s", facetName); 107 final String error = String.format("Unknown facet name: %s", facetName);
86 throw new UnsupportedOperationException(error); 108 throw new UnsupportedOperationException(error);
87 } 109 }
110
111 private final String generateFieldHeightSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme,
112 final boolean visible, final int fieldIndex) {
113
114 final BezugswstMainCalculationResult data = (BezugswstMainCalculationResult) getResult(generator, bundle);
115 final double[][] points = data.getFieldValuePoints(fieldIndex, BunduResultType.bedHeightFields);
116
117 return buildSeriesForPoints(points, generator, bundle, theme, visible, null);
118 }
88 } 119 }

http://dive4elements.wald.intevation.org