Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelFacet.java @ 9259:66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
author | mschaefer |
---|---|
date | Mon, 16 Jul 2018 08:43:07 +0200 |
parents | a4121ec450d6 |
children |
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.sinfo.predefinedchannel; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.common.DefaultCalculationResult; import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.BlackboardDataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.model.sinfo.Channel; import org.dive4elements.river.model.sinfo.ChannelValue; /** * Facet for a river channel value series loaded from the database * * @author Matthias Schäfer */ public class PredefinedChannelFacet extends BlackboardDataFacet implements FacetTypes { private static final long serialVersionUID = 56753318291306671L; public PredefinedChannelFacet(final String name, final String description, final String yAxisLabel) { super(0, name, description); this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); this.metaData.put("Y", yAxisLabel); } /** * Returns the data this facet requires. * * @param artifact * the owner artifact. * @param context * the CallContext (ignored). * * @return * the data as PredefinedChannelQueryCalculationResult */ @Override public Object getData(final Artifact artifact, final CallContext context) { final PredefinedChannelAccess access = new PredefinedChannelAccess((D4EArtifact) artifact); final Channel series = Channel.getSeries(access.getId()); final List<ChannelValue> values = ChannelValue.getValues(series, access.getFrom(true), access.getTo(true)); final Collection<ResultRow> rows = new ArrayList<>(); for (final ChannelValue value : values) { rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) // .putValue(SInfoResultType.channelWidth, value.getWidth()) // .putValue(SInfoResultType.channelDepth, value.getDepth())); } return new DefaultCalculationResult(series.getFilename(), rows); } /** * Create a deep copy of this Facet. * * @return a deep copy. */ @Override public PredefinedChannelFacet deepCopy() { final PredefinedChannelFacet copy = new PredefinedChannelFacet(this.name, this.description, this.metaData.get("Y")); copy.set(this); return copy; } }