Mercurial > dive4elements > river
changeset 4508:03b8d10a99c0
FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 14 Nov 2012 13:46:50 +0100 (2012-11-14) |
parents | 976ff4b74b96 |
children | acd7437f66f0 |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifact.java |
diffstat | 1 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifact.java Wed Nov 14 12:26:45 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifact.java Wed Nov 14 13:46:50 2012 +0100 @@ -1,5 +1,18 @@ package de.intevation.flys.artifacts; +import de.intevation.artifacts.CallContext; + +import de.intevation.flys.artifacts.geom.Lines; +import de.intevation.flys.artifacts.StaticWKmsArtifact; + +import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.artifacts.model.WKms; +import de.intevation.flys.artifacts.model.fixings.FixRealizingResult; + +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + +import de.intevation.flys.model.FastCrossSectionLine; + import org.apache.log4j.Logger; /** @@ -9,6 +22,7 @@ */ public class FixationArtifact extends FLYSArtifact +implements WaterLineArtifact { /** The logger for this class. */ private static Logger logger = Logger.getLogger(FixationArtifact.class); @@ -34,5 +48,34 @@ public String getName() { return ARTIFACT_NAME; } + + @Override + public Lines.LineData getWaterLines( + int facetIdx, + FastCrossSectionLine csl, + double d, + double w, + CallContext context + ) { + FixRealizingResult result = (FixRealizingResult) + ((CalculationResult)this.compute(context, ComputeType.ADVANCE, false)).getData(); + + WKms wkms = result.getWQKms()[facetIdx]; + + double km = csl.getKm(); + + // Find W at km. + double wAtKm; + + wAtKm = StaticWKmsArtifact.getWAtKm(wkms, km); + + if (wAtKm == -1 || Double.isNaN(wAtKm)) { + logger.warn("Waterlevel at km " + km + " unknown."); + return new Lines.LineData(new double[][] {{}}, 0d, 0d); + } + + // This should be FixRealizationResult, which can be getWQKms()ed + return Lines.createWaterLines(csl.getPoints(), wAtKm); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :