Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstHeightProcessor.java Mon Aug 20 18:50:33 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstHeightProcessor.java Tue Aug 21 13:41:18 2018 +0200 @@ -23,6 +23,7 @@ import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.LongitudinalSectionGenerator; +import org.dive4elements.river.model.BedHeightValueType; import org.dive4elements.river.themes.ThemeDocument; /** @@ -42,6 +43,12 @@ private static final String FACET_BEDHEIGHT_DESCRIPTION = "bundu_facet_bedheight.description"; + public static final String FACET_FIELD_BEDHEIGHT_PREFIX = "bundu_facet_bedheight_"; + + private static final String FACET_FIELD_BEDHEIGHT_FORMAT = FACET_FIELD_BEDHEIGHT_PREFIX + "%02d"; + + private static final String FACET_FIELD_BEDHEIGHT_DESCRIPTION = "bundu_facet_field_bedheight.description"; + private static final String AXIS_LABEL = LongitudinalSectionGenerator.I18N_YAXIS_LABEL; private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); @@ -49,6 +56,8 @@ static { HANDLED_FACET_TYPES.add(FACET_CHANNELMIN); HANDLED_FACET_TYPES.add(FACET_BEDHEIGHT); + for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++) + HANDLED_FACET_TYPES.add(String.format(FACET_FIELD_BEDHEIGHT_FORMAT, i)); } public BezugswstHeightProcessor() { @@ -69,10 +78,23 @@ return new BezugswstResultFacet(facetIndex, resultIndex, FACET_BEDHEIGHT, description, AXIS_LABEL, id, hash); } + public static Facet createFieldBedheightFacet(final CallContext context, final String hash, final String id, final int facetIndex, + final int resultIndex, final int fieldIndex) { + + final String description = Resources.getMsg(context.getMeta(), FACET_FIELD_BEDHEIGHT_DESCRIPTION, FACET_FIELD_BEDHEIGHT_DESCRIPTION, fieldIndex); + final String facetName = String.format(FACET_FIELD_BEDHEIGHT_FORMAT, fieldIndex); + return new BezugswstResultFacet(facetIndex, resultIndex, facetName, description, AXIS_LABEL, id, hash); + } + @Override protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { - return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE); + if (bundle.getFacetName().startsWith(FACET_FIELD_BEDHEIGHT_PREFIX)) { + final int fieldIndex = Integer.parseInt(bundle.getFacetName().substring(FACET_FIELD_BEDHEIGHT_PREFIX.length())); + return generateFieldHeightSeries(generator, bundle, theme, visible, fieldIndex); + } + + return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null); } protected AbstractResultType doGetType(final String facetName) { @@ -85,4 +107,13 @@ final String error = String.format("Unknown facet name: %s", facetName); throw new UnsupportedOperationException(error); } + + private final String generateFieldHeightSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, + final boolean visible, final int fieldIndex) { + + final BezugswstMainCalculationResult data = (BezugswstMainCalculationResult) getResult(generator, bundle); + final double[][] points = data.getFieldValuePoints(fieldIndex, BunduResultType.bedHeightFields); + + return buildSeriesForPoints(points, generator, bundle, theme, visible, null); + } } \ No newline at end of file