Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstDepthProcessor.java @ 9451:fd6621f47a72
Bundu bzws density calculation completed
author | mschaefer |
---|---|
date | Thu, 23 Aug 2018 10:57:40 +0200 |
parents | ecadc9ed0ba0 |
children | 3fa8551c3d1b |
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.bundu.bezugswst; import java.util.HashSet; import java.util.Set; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.bundu.BunduResultType; import org.dive4elements.river.artifacts.common.AbstractProcessor; import org.dive4elements.river.artifacts.common.AbstractResultType; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.model.BedHeightValueType; import org.dive4elements.river.themes.ThemeDocument; /** * Processor to generate the facets and data series of a bundu bezugswst depth longitudinal section * * @author Matthias Schäfer * */ public final class BezugswstDepthProcessor extends AbstractProcessor { private static final String FACET_FLOWDEPTH_FILTERED = "bundu_facet_flowdepth.filtered"; private static final String FACET_FLOWDEPTH_FILTERED_DESCRIPTION = "bundu_facet_flowdepth.filtered.description"; public static final String FACET_CHANNELDEPTH = "bundu_facet_channeldepth"; private static final String FACET_CHANNELDEPTH_DESCRIPTION = "bundu_facet_channeldepth.description"; public static final String FACET_FIELD_DEPTH_PREFIX = "bundu_facet_depth_"; private static final String FACET_FIELD_DEPTH_FORMAT = FACET_FIELD_DEPTH_PREFIX + "%02d.filtered"; private static final String FACET_FIELD_DEPTH_DESCRIPTION = "bundu_facet_field_depth.description"; private static final String AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); static { HANDLED_FACET_TYPES.add(FACET_FLOWDEPTH_FILTERED); HANDLED_FACET_TYPES.add(FACET_CHANNELDEPTH); for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++) HANDLED_FACET_TYPES.add(String.format(FACET_FIELD_DEPTH_FORMAT, i)); } public BezugswstDepthProcessor() { super(AXIS_LABEL, HANDLED_FACET_TYPES); } public static Facet createFlowdepthFilteredFacet(final CallContext context, final String hash, final String id, final int facetIndex, final int resultIndex, final String seriesName) { final String description = Resources.getMsg(context.getMeta(), FACET_FLOWDEPTH_FILTERED_DESCRIPTION, FACET_FLOWDEPTH_FILTERED_DESCRIPTION, seriesName); return new BezugswstResultFacet(facetIndex, resultIndex, FACET_FLOWDEPTH_FILTERED, description, AXIS_LABEL, id, hash); } public static Facet createChanneldepthFacet(final CallContext context, final String hash, final String id, final int facetIndex, final int resultIndex) { final String description = Resources.getMsg(context.getMeta(), FACET_CHANNELDEPTH_DESCRIPTION, FACET_CHANNELDEPTH_DESCRIPTION); return new BezugswstResultFacet(facetIndex, resultIndex, FACET_CHANNELDEPTH, description, AXIS_LABEL, id, hash); } public static Facet createFieldDepthFacet(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_DEPTH_DESCRIPTION, FACET_FIELD_DEPTH_DESCRIPTION, fieldIndex); final String facetName = String.format(FACET_FIELD_DEPTH_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) { if (bundle.getFacetName().startsWith(FACET_FIELD_DEPTH_PREFIX)) { final int fieldIndex = Integer.parseInt(bundle.getFacetName().substring(FACET_FIELD_DEPTH_PREFIX.length(), FACET_FIELD_DEPTH_PREFIX.length() + 2)); return generateFieldDepthSeries(generator, bundle, theme, visible, fieldIndex); } return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null); } protected AbstractResultType doGetType(final String facetName) { if (FACET_FLOWDEPTH_FILTERED.contentEquals(facetName)) return SInfoResultType.flowdepth; if (FACET_CHANNELDEPTH.contentEquals(facetName)) return BunduResultType.channelDepth; final String error = String.format("Unknown facet name: %s", facetName); throw new UnsupportedOperationException(error); } private final String generateFieldDepthSeries(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.depthFields); return buildSeriesForPoints(points, generator, bundle, theme, visible, null); } }