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: teichmann@5831: import org.dive4elements.artifacts.CallContext; felix@4508: teichmann@5831: import org.dive4elements.river.artifacts.geom.Lines; felix@4508: 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: teichmann@5831: import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; teichmann@5831: teichmann@5831: import org.dive4elements.river.model.FastCrossSectionLine; felix@4508: raimund@2651: import org.apache.log4j.Logger; raimund@2651: raimund@2651: /** raimund@2651: * The default fixation analysis artifact. raimund@2651: * raimund@2651: * @author Raimund Renkert raimund@2651: */ raimund@2651: public class FixationArtifact teichmann@5867: extends D4EArtifact felix@4508: implements WaterLineArtifact sascha@3774: { raimund@2651: /** The logger for this class. */ raimund@2651: private static Logger logger = Logger.getLogger(FixationArtifact.class); raimund@2651: raimund@2651: /** The name of the artifact. */ raimund@2651: public 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() { christian@3917: logger.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 felix@4508: public Lines.LineData getWaterLines( felix@4508: int facetIdx, felix@4508: FastCrossSectionLine csl, felix@4508: double d, felix@4508: double w, felix@4508: CallContext context felix@4508: ) { felix@4508: FixRealizingResult result = (FixRealizingResult) felix@4508: ((CalculationResult)this.compute(context, ComputeType.ADVANCE, false)).getData(); teichmann@4736: felix@4508: WKms wkms = result.getWQKms()[facetIdx]; felix@4508: felix@4508: double km = csl.getKm(); felix@4508: felix@4508: // Find W at km. felix@4508: double wAtKm; felix@4508: felix@4508: wAtKm = StaticWKmsArtifact.getWAtKm(wkms, km); felix@4508: felix@4508: if (wAtKm == -1 || Double.isNaN(wAtKm)) { felix@4508: logger.warn("Waterlevel at km " + km + " unknown."); felix@4508: return new Lines.LineData(new double[][] {{}}, 0d, 0d); felix@4508: } felix@4508: felix@4508: // This should be FixRealizationResult, which can be getWQKms()ed felix@4508: return Lines.createWaterLines(csl.getPoints(), wAtKm); felix@4508: } raimund@2651: } felix@2728: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :