view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstDepthProcessor.java @ 9432:d194c5b24bf8

Added bundu bzws w calculation and longitudinal sections of wspl and depth
author mschaefer
date Mon, 20 Aug 2018 09:46:02 +0200
parents
children ecadc9ed0ba0
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.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";

    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);
    }

    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);
    }

    @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);
    }

    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);
    }
}

http://dive4elements.wald.intevation.org