teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts; felix@4508: gernotbelger@9425: import java.io.Serializable; felix@4508: gernotbelger@9425: import org.apache.log4j.Logger; gernotbelger@9425: import org.dive4elements.artifacts.CallContext; teichmann@5831: import org.dive4elements.river.artifacts.model.CalculationResult; teichmann@5831: import org.dive4elements.river.artifacts.model.WKms; teichmann@5831: import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; teichmann@5831: import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; teichmann@5831: raimund@2651: /** raimund@2651: * The default fixation analysis artifact. raimund@2651: * raimund@2651: * @author Raimund Renkert raimund@2651: */ gernotbelger@9425: public class FixationArtifact extends D4EArtifact implements WaterLineArtifact { gernotbelger@9425: gernotbelger@9425: private static final long serialVersionUID = 1L; gernotbelger@9425: teichmann@8202: /** The log for this class. */ teichmann@8202: private static Logger log = Logger.getLogger(FixationArtifact.class); raimund@2651: raimund@2651: /** The name of the artifact. */ gernotbelger@9425: private static final String ARTIFACT_NAME = "fixanalysis"; raimund@2651: felix@4418: /* FacetActivity for this artifact is registered in FixAnalysisCompute . */ felix@4418: raimund@2651: /** raimund@2651: * The default constructor. raimund@2651: */ raimund@2651: public FixationArtifact() { teichmann@8202: log.debug("ctor()"); raimund@2651: } raimund@2651: raimund@2651: /** raimund@2651: * Returns the name of the concrete artifact. raimund@2651: * raimund@2651: * @return the name of the concrete artifact. raimund@2651: */ sascha@3193: @Override raimund@2651: public String getName() { raimund@2651: return ARTIFACT_NAME; raimund@2651: } felix@4508: felix@6496: /** Calculate waterlines against a cross section. */ felix@4508: @Override gernotbelger@9425: public double getWaterLevel(final ComputeType type, final String hash, final String stateId, final double currentKm, final Serializable waterLineIndex, gernotbelger@9425: final double nextKm, final double prevKm, final CallContext context) { gernotbelger@9425: final FixRealizingResult result = (FixRealizingResult) ((CalculationResult) this.compute(context, ComputeType.ADVANCE, false)).getData(); teichmann@4736: gernotbelger@9425: final int wstIndex = (Integer) waterLineIndex; felix@4508: gernotbelger@9425: final WKms wkms = result.getWQKms()[wstIndex]; felix@4508: felix@4508: // Find W at km. gernotbelger@9425: final double wAtKm = StaticWKmsArtifact.getWAtKm(wkms, currentKm); felix@4508: felix@4508: if (wAtKm == -1 || Double.isNaN(wAtKm)) { gernotbelger@9425: log.warn("Waterlevel at km " + currentKm + " unknown."); gernotbelger@9425: return Double.NaN; felix@4508: } felix@4508: gernotbelger@9425: return wAtKm; felix@4508: } gernotbelger@9425: }