diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java @ 6533:30c6da3bfc86

In analogy to w values allow q values to be calculated at the correct km in fix settings (bug spotted while working on issue1370).
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 03 Jul 2013 09:34:02 +0200
parents af13ceeba52a
children 5d071e1cb17c
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java	Tue Jul 02 15:43:11 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java	Wed Jul 03 09:34:02 2013 +0200
@@ -25,6 +25,7 @@
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 
 import org.dive4elements.river.exports.DurationCurveGenerator;
+import org.dive4elements.river.exports.fixings.FixChartGenerator;
 
 
 /**
@@ -89,7 +90,8 @@
      * Returns the data this facet requires.
      *
      * @param artifact the owner artifact.
-     * @param context  the CallContext (ignored).
+     * @param context  the CallContext (can be used to find out if in
+     *                 navigable fixation-setting, or durationcurve).
      *
      * @return the data.
      */
@@ -105,6 +107,15 @@
             getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
         if (providers.size() < 1) {
             logger.warn("Could not find durationcurve data provider.");
+            // Do we have a current km in context?
+            // If so, we are likely fetching data for a navigable
+            // diagram (i.e. in fixation branch).
+            if (context.getContextValue(FixChartGenerator.CURRENT_KM) != null) {
+                Double ckm = (Double) context.getContextValue(FixChartGenerator.CURRENT_KM);
+                // Return linearly interpolated values, in m if not at gauge,
+                // in cm if at gauge.
+                qs = mvArtifact.getMainValuesQ(new double[] {ckm});
+            }
         }
         else {
             wqdays = (WQDay) providers.get(0).provideData(

http://dive4elements.wald.intevation.org