[Dive4elements-commits] [PATCH 4 of 7] FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections
Wald Commits
scm-commit at wald.intevation.org
Wed Nov 14 13:43:25 CET 2012
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1352897210 -3600
# Node ID 03b8d10a99c0b432645f01c5e2d41bef2f677fd6
# Parent 976ff4b74b96c5e1a1a5504e2a4db024d96f2dea
FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
diff -r 976ff4b74b96 -r 03b8d10a99c0 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifact.java
--- 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 :
More information about the Dive4elements-commits
mailing list