changeset 3080:dc2765e31e1f

Added getData method with an additional km parameter. flys-artifacts/trunk@4676 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 15 Jun 2012 12:42:13 +0000
parents 8ad8a227d983
children 26119b7b3154
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java
diffstat 8 files changed, 80 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jun 15 12:42:13 2012 +0000
@@ -1,3 +1,15 @@
+2012-06-15  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java:
+	  The getData() method now takes a km parameter to get the data at a specific
+	  km.
+
 2012-06-15  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/sq/SQ.java: New model to
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -29,6 +29,8 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixAnalysisEventsFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixAnalysisEventsFacet() {
     }
@@ -47,6 +49,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -70,11 +78,9 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
-
             KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods();
             KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry =
-                kmPeriods.binarySearch(km);
+                kmPeriods.binarySearch(currentKm);
 
             if(kmPeriodsEntry == null) {
                 return null;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -29,6 +29,8 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixAnalysisPeriodsFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixAnalysisPeriodsFacet() {
     }
@@ -47,6 +49,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -70,11 +78,9 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
-
             KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods();
             KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry =
-                kmPeriods.binarySearch(km);
+                kmPeriods.binarySearch(currentKm);
 
             if (kmPeriodsEntry == null) {
                 return null;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -29,6 +29,8 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixAvSectorFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixAvSectorFacet() {
     }
@@ -45,6 +47,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -68,16 +76,12 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
-
-            logger.debug("Current KM = " + km);
-
             KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods();
             KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry =
-                kmPeriods.binarySearch(km);
+                kmPeriods.binarySearch(currentKm);
 
             if (kmPeriodsEntry == null) {
-                logger.warn("No analysis periods found for km '" + km + "'");
+                logger.warn("No analysis periods found for km '" + currentKm + "'");
                 return null;
             }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -33,6 +33,8 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixDerivateFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixDerivateFacet() {
     }
@@ -46,6 +48,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -68,14 +76,12 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
-
             String function = access.getFunction();
             Function ff = FunctionFactory.getInstance().getFunction(function);
             Function.Derivative fd = ff.getDerivative();
 
             Parameters params = result.getParameters();
-            int row = params.binarySearch("km", km, Math.pow(10, -4));
+            int row = params.binarySearch("km", currentKm, Math.pow(10, -4));
             if(row < 0) {
                 row = -row - 1;
                 logger.debug("getData: no direct hit in params.binarySearch");
@@ -88,7 +94,7 @@
             de.intevation.flys.artifacts.math.Function mf =
                 fd.instantiate(coeffs);
 
-            double maxQ = getMaxQ(result, km);
+            double maxQ = getMaxQ(result, currentKm);
 
             FixFunction fix = new FixFunction(
                 "",
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -29,6 +29,8 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixOutlierFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixOutlierFacet() {
     }
@@ -42,6 +44,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -65,10 +73,9 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
             KMIndex<QW []> kmQWs = result.getOutliers();
 
-            KMIndex.Entry<QW []> qwsEntry = kmQWs.binarySearch(km);
+            KMIndex.Entry<QW []> qwsEntry = kmQWs.binarySearch(currentKm);
             QW[] qws = null;
             if(qwsEntry != null) {
                 qws = qwsEntry.getValue();
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -29,6 +29,8 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixReferenceEventsFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixReferenceEventsFacet() {
     }
@@ -47,6 +49,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -70,9 +78,8 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
             KMIndex<QW []> kmQWs = result.getReferenced();
-            KMIndex.Entry<QW []> kmQWsEntry = kmQWs.binarySearch(km);
+            KMIndex.Entry<QW []> kmQWsEntry = kmQWs.binarySearch(currentKm);
             QW[] qws = null;
             if (kmQWsEntry != null) {
                 qws = kmQWsEntry.getValue();
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java	Fri Jun 15 12:23:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java	Fri Jun 15 12:42:13 2012 +0000
@@ -30,8 +30,11 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixWQCurveFacet.class);
 
+    private double currentKm;
+
     /** Trivial Constructor. */
     public FixWQCurveFacet() {
+        currentKm = 0;
     }
 
 
@@ -43,6 +46,12 @@
     }
 
 
+    public Object getData(Artifact artifact, CallContext context, double km) {
+        this.currentKm = km;
+        return getData(artifact, context);
+    }
+
+
     /**
      * Returns the data this facet requires.
      *
@@ -65,8 +74,7 @@
 
             FixResult result = (FixResult) res.getData();
 
-            double km = access.getCurrentKm();
-            logger.debug("FixWQCurveFacet.getData: km = " + km);
+            logger.debug("FixWQCurveFacet.getData: km = " + currentKm);
 
             String function = access.getFunction();
             Function ff = FunctionFactory.getInstance().getFunction(function);
@@ -78,7 +86,7 @@
             Parameters params = result.getParameters();
             String[] paramNames = ff.getParameterNames();
 
-            double [] coeffs = params.interpolate("km", km, paramNames);
+            double [] coeffs = params.interpolate("km", currentKm, paramNames);
 
             if (coeffs == null) {
                 return null;
@@ -87,7 +95,7 @@
             de.intevation.flys.artifacts.math.Function mf =
                 ff.instantiate(coeffs);
 
-            double maxQ = getMaxQ(params, km);
+            double maxQ = getMaxQ(params, currentKm);
 
             logger.debug("getData: maxQ = " + maxQ);
 

http://dive4elements.wald.intevation.org