[Dive4elements-commits] [PATCH 1 of 6] RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact
Wald Commits
scm-commit at wald.intevation.org
Wed Apr 24 08:55:52 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1366784238 -7200
# Node ID cce12c06466fcd83dcb87507f088bf4d9caf8544
# Parent 53cff50918b12ffee3739224d87c4396853ad76a
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
diff -r 53cff50918b1 -r cce12c06466f flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java Tue Apr 23 18:47:57 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java Wed Apr 24 08:17:18 2013 +0200
@@ -10,6 +10,7 @@
import de.intevation.artifacts.DataProvider;
import de.intevation.flys.artifacts.StaticWKmsArtifact;
+import de.intevation.flys.artifacts.StaticWQKmsArtifact;
import de.intevation.flys.artifacts.math.Linear;
/**
@@ -36,7 +37,7 @@
protected Point2D calculateDurationCurvePoint(CallContext context,
- StaticWKmsArtifact artifact)
+ WKms wKms)
{
// TODO here and in reference curve calc: Do warn if more than 1
// provider found or (way better) handle it.
@@ -69,7 +70,7 @@
if (wqdays != null) {
// Which W at this km?
- double w = artifact.getWAtKmLin(artifact.getWKms(0), km);
+ double w = StaticWKmsArtifact.getWAtKmLin(wKms, km);
if (w == -1) {
logger.warn("w is -1, already bad sign!");
}
@@ -110,7 +111,8 @@
* the Ws from start and end km param of the reference curve.
*/
public Point2D calculateReferenceCurvePoint(CallContext context,
- StaticWKmsArtifact artifact) {
+ WKms wKms) {
+
List<DataProvider> providers = context.
getDataProvider(ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM);
if (providers.size() < 1) {
@@ -129,9 +131,10 @@
provideData(ReferenceCurveFacet.BB_REFERENCECURVE_ENDKMS, null, context);
logger.debug("Got s " + start + " e " + ends);
- double startW = artifact.getWAtKmLin(artifact.getWKms(0), start.doubleValue());
+
+ double startW = StaticWKmsArtifact.getWAtKmLin(wKms, start.doubleValue());
// TODO handle multiple ends.
- double endW = artifact.getWAtKmLin(artifact.getWKms(0), ends[0]);
+ double endW = StaticWKmsArtifact.getWAtKmLin(wKms, ends[0]);
logger.debug("Gotw s " + startW + " e " + endW);
return new Point2D.Double(startW, endW);
}
@@ -147,17 +150,28 @@
*/
@Override
public Object getData(Artifact artifact, CallContext context) {
- StaticWKmsArtifact staticData = (StaticWKmsArtifact) artifact;
+ WKms wKms = null;
+ if (artifact instanceof StaticWKmsArtifact) {
+ wKms = ((StaticWKmsArtifact) artifact).getWKms(0);
+ }
+ else if (artifact instanceof StaticWQKmsArtifact) {
+ wKms = ((StaticWQKmsArtifact) artifact).getWQKms();
+ }
+ else {
+ logger.error("Cannot handle Artifact to create relative point.");
+ return null;
+ }
+
// Find out whether we live in a duration curve context, there we would
// provide only a single point.
if (context.getDataProvider(
DurationCurveFacet.BB_DURATIONCURVE_KM).size() > 0) {
- return calculateDurationCurvePoint(context, staticData);
+ return calculateDurationCurvePoint(context, wKms);
}
else if (context.getDataProvider(
ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM).size() > 0) {
- return calculateReferenceCurvePoint(context, staticData);
+ return calculateReferenceCurvePoint(context, wKms);
}
// TODO better signal failure.
More information about the Dive4elements-commits
mailing list