changeset 8331:27d42c9ee367

Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
author "Tom Gottfried <tom@intevation.de>"
date Fri, 26 Sep 2014 09:44:48 +0200
parents e87a993c6611
children 3baa6290cebf
files artifacts/doc/conf/artifacts/chart.xml artifacts/doc/conf/artifacts/gaugedischarge.xml artifacts/doc/conf/artifacts/gaugedischargecurve.xml artifacts/doc/conf/artifacts/winfo.xml artifacts/doc/conf/themes.xml artifacts/doc/conf/themes/default.xml artifacts/doc/conf/themes/second.xml artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java
diffstat 15 files changed, 112 insertions(+), 297 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/chart.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/artifacts/chart.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -141,8 +141,8 @@
                         <facet name="empty.facet" description="Empty"/>
                         <facet name="computed_discharge_curve.manualpoints"/>
                         <facet name="computed_discharge_curve.q" description="facet.computed_discharge_curve.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.q" description="facet.computed_discharge_curve.mainvalues.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.w" description="facet.computed_discharge_curve.mainvalues.w"/>
+                        <facet name="mainvalues.q"/>
+                        <facet name="mainvalues.w"/>
                         <facet name="other.wqkms" description="facet.other.wqkms"/>
                         <facet name="other.wq" description="Point-like data like fixations"/>
                         <facet name="other.wq" description="Point-like data like fixations"/>
@@ -161,8 +161,8 @@
                         <facet name="duration_curve.manualpoints"/>
                         <facet name="duration_curve.w" description="facet.duration_curve.w"/>
                         <facet name="duration_curve.q" description="facet.duration_curve.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.q" description="Q Main Values"/>
-                        <facet name="computed_discharge_curve.mainvalues.w" description="W Main Values"/>
+                        <facet name="mainvalues.q" description="Q Main Values"/>
+                        <facet name="mainvalues.w" description="W Main Values"/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/artifacts/doc/conf/artifacts/gaugedischarge.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/artifacts/gaugedischarge.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -8,8 +8,8 @@
         <outputmode name="computed_discharge_curve" description="computed_discharge_curve" mime-type="image/png" type="chart">
           <facets>
             <facet name="discharge_curve.curve" description="facet.discharge_curve.curve" />
-            <facet name="computed_discharge_curve.mainvalues.q" description="mainvalues.q"/>
-            <facet name="computed_discharge_curve.mainvalues.w" description="mainvalues.w"/>
+            <facet name="mainvalues.q"/>
+            <facet name="mainvalues.w"/>
             <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
             <facet name="heightmarks_points" description="facet.other.wqkms"/>
             <facet name="other.wqkms" description="facet.other.wqkms"/>
--- a/artifacts/doc/conf/artifacts/gaugedischargecurve.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/artifacts/gaugedischargecurve.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -16,8 +16,8 @@
                <outputmode name="discharge_curve" description="output.discharge_curve" mime-type="image/png" type="chart">
                    <facets>
                        <facet name="gauge_discharge_curve"/>
-                       <facet name="mainvalues.q" description="mainvalues.q"/>
-                       <facet name="computed_discharge_curve.mainvalues.w" description="mainvalues.w"/>
+                       <facet name="mainvalues.q"/>
+                       <facet name="mainvalues.w"/>
                        <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
                        <facet name="heightmarks_points" description="facet.other.wqkms"/>
                        <facet name="other.wqkms" description="facet.other.wqkms"/>
--- a/artifacts/doc/conf/artifacts/winfo.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/artifacts/winfo.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -298,8 +298,8 @@
                         <facet name="duration_curve.w" description="facet.duration_curve.w"/>
                         <facet name="duration_curve.q" description="facet.duration_curve.q"/>
                         <facet name="other.wq"         description="Point-like data like fixations"/>
-                        <facet name="duration_curve.mainvalues.q" description="Q Main Values at optional second axis"/>
-                        <facet name="computed_discharge_curve.mainvalues.w" description="W Main Values"/>
+                        <facet name="mainvalues.q" description="Q Main Values at optional second axis"/>
+                        <facet name="mainvalues.w" description="W Main Values"/>
                         <facet name="duration_curve.manualpoints" description="Manuelle Punkte"/>
                         <facet name="relativepoint"    description="Points at curve"/>
                     </facets>
@@ -323,8 +323,8 @@
                 <outputmode name="computed_discharge_curve" description="output.computed_discharge_curve" mime-type="image/png" type="chart">
                     <facets>
                         <facet name="computed_discharge_curve.q" description="facet.computed_discharge_curve.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.q" description="facet.computed_discharge_curve.mainvalues.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.w" description="facet.computed_discharge_curve.mainvalues.w"/>
+                        <facet name="mainvalues.q" description="facet.computed_discharge_curve.mainvalues.q"/>
+                        <facet name="mainvalues.w" description="facet.computed_discharge_curve.mainvalues.w"/>
                         <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
                         <facet name="heightmarks_points" description="facet.other.wqkms"/>
                         <facet name="other.wqkms.w" description="facet.other.wqkms"/>
--- a/artifacts/doc/conf/themes.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/themes.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -150,9 +150,6 @@
         <mapping from="discharge_longitudinal_section.w" to="DischargeLongitudinalSectionW" />
         <mapping from="discharge_longitudinal_section.c" to="DischargeLongitudinalSectionC" />
         <mapping from="discharge_longitudinal_section.q" to="DischargeLongitudinalSectionQ" />
-        <mapping from="computed_discharge_curve.mainvalues.q" to="MainValuesQVerticalText" />
-        <mapping from="computed_discharge_curve.mainvalues.w" to="MainValuesW" />
-        <mapping from="duration_curve.mainvalues.q" to="MainValuesQ" />
         <mapping from="mainvalues.q" to="MainValuesQ" />
         <mapping from="mainvalues.w" to="MainValuesW" />
         <mapping from="longitudinal_section.annotations" to="Annotations" />
--- a/artifacts/doc/conf/themes/default.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/themes/default.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -14,20 +14,6 @@
         </fields>
     </theme>
 
-    <theme name="MainValuesQVerticalText">
-        <inherits>
-            <inherit from="Lines" />
-        </inherits>
-        <fields>
-            <field name="linecolor" type="Color" display="Farbe"
-                default="200, 0, 15" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="false" />
-            <field name="showlinelabel" type="boolean"
-                display="Linienbeschriftung anzeigen" default="false" hints="hidden" />
-        </fields>
-    </theme>
-
     <theme name="MainValuesW">
         <inherits>
             <inherit from="Lines" />
--- a/artifacts/doc/conf/themes/second.xml	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/doc/conf/themes/second.xml	Fri Sep 26 09:44:48 2014 +0200
@@ -14,20 +14,6 @@
         </fields>
     </theme>
 
-    <theme name="MainValuesQVerticalText">
-        <inherits>
-            <inherit from="Lines" />
-        </inherits>
-        <fields>
-            <field name="linecolor" type="Color" display="Farbe"
-                default="200, 0, 15" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="false" />
-            <field name="showlinelabel" type="boolean"
-                display="Linienbeschriftung anzeigen" default="false" hints="hidden" />
-        </fields>
-    </theme>
-
     <theme name="MainValuesW">
         <inherits>
             <inherit from="Lines" />
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Fri Sep 26 09:44:48 2014 +0200
@@ -32,6 +32,7 @@
 import org.dive4elements.river.model.MainValue;
 import org.dive4elements.river.model.River;
 
+import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.model.Calculation;
 import org.dive4elements.river.artifacts.model.FacetTypes;
@@ -44,8 +45,6 @@
 import org.dive4elements.river.artifacts.states.StaticState;
 import org.dive4elements.river.artifacts.resources.Resources;
 
-import org.dive4elements.river.utils.RiverUtils;
-
 
 /**
  * Artifact to access main and extreme values of a river.
@@ -123,58 +122,18 @@
         log.debug("mainvalue restriction " + restriction);
         boolean restricted = restriction.endsWith("q") || restriction.endsWith("w");
         if (!restricted || restriction.endsWith("q")) {
-            Facet qfacet0 = new MainValuesQFacet(
-                DURATION_MAINVALUES_Q,
-                Resources.getMsg(
-                    callMeta,
-                    "facet.discharge_curves.mainvalues.q"),
-                false);
-            Facet qfacet1 = new MainValuesQFacet(
-                COMPUTED_DISCHARGE_MAINVALUES_Q,
-                Resources.getMsg(
-                    callMeta,
-                    "facet.discharge_curves.mainvalues.q"),
-                false);
-            Facet qfacet2 = new MainValuesQFacet(
-                MAINVALUES_Q,
-                Resources.getMsg(
-                    callMeta,
-                    "facet.discharge_curves.mainvalues.q"),
-                true);
-            Facet qfacet3 = new MainValuesQFacet(
-                HISTORICAL_DISCHARGE_MAINVALUES_Q,
-                Resources.getMsg(
-                    callMeta,
-                    "historical_discharge.mainvalues.q"),
-                false);
-
-            fs.add(qfacet0);
-            fs.add(qfacet1);
-            fs.add(qfacet2);
-            fs.add(qfacet3);
+            fs.add(new MainValuesQFacet(
+                    MAINVALUES_Q,
+                    Resources.getMsg(
+                        callMeta,
+                        "facet.discharge_curves.mainvalues.q")));
         }
         if (!restricted || restriction.endsWith("w")) {
-            Facet wfacet1 = new MainValuesWFacet(
-                COMPUTED_DISCHARGE_MAINVALUES_W,
-                Resources.getMsg(
-                    callMeta,
-                    "facet.discharge_curves.mainvalues.w"),
-                false);
-            Facet wfacet2 = new MainValuesWFacet(
-                MAINVALUES_W,
-                Resources.getMsg(
-                    callMeta,
-                    "facet.discharge_curves.mainvalues.w"),
-                true);
-            Facet wfacet3 = new MainValuesWFacet(
-                HISTORICAL_DISCHARGE_MAINVALUES_W,
-                Resources.getMsg(
-                    callMeta,
-                    "historical_discharge.mainvalues.w"),
-                true);
-            fs.add(wfacet1);
-            fs.add(wfacet2);
-            fs.add(wfacet3);
+            fs.add(new MainValuesWFacet(
+                    MAINVALUES_W,
+                    Resources.getMsg(
+                        callMeta,
+                        "facet.discharge_curves.mainvalues.w")));
         }
     }
 
@@ -238,8 +197,8 @@
     protected void initialize(Artifact artifact, Object context, CallMeta meta) {
         log.debug("MainValuesArtifact.initialize");
         D4EArtifact winfo = (D4EArtifact) artifact;
-        RangeAccess rangeAccess = new RangeAccess(winfo);
-        double [] locations = rangeAccess.getKmRange();
+        River river = new RiverAccess(winfo).getRiver();
+        double [] locations = new RangeAccess(winfo).getKmRange();
 
         if (locations != null) {
             double location = locations[0];
@@ -320,7 +279,7 @@
      *         invalid parameterization.
      */
     protected Gauge getGauge(double km) {
-        River river = RiverUtils.getRiver(this);
+        River river = new RiverAccess((D4EArtifact)this).getRiver();
 
         if (river == null) {
             log.error("River is null");
@@ -331,33 +290,6 @@
     }
 
     /**
-     * Access the Gauge that the mainvalues are taken from.
-     * @return Gauge that main values are taken from or null in case of
-     *         invalid parameterization.
-     */
-    protected Gauge getGauge() {
-        River river = RiverUtils.getRiver(this);
-
-        // TODO use helper to get location as double
-        String locationStr = getDataAsString("ld_locations");
-
-        if (river == null) {
-            log.error("River is null");
-            return null;
-        }
-
-        if (locationStr == null) {
-            log.error("Locationstr is null");
-            return null;
-        }
-
-        double location = Double.parseDouble(locationStr);
-
-        return river.determineGaugeByPosition(location);
-    }
-
-
-    /**
      * Get current location.
      * @return the location.
      */
@@ -369,24 +301,34 @@
 
     /**
      * Get a list of "Q" main values.
+     * @param Array of length 1 (isn't it lovely?) giving the station for
+     *        which the main values should be returned
      * @return list of Q main values.
      */
-    public List<NamedDouble> getMainValuesQ(double[] kms) {
-        log.debug("MainValuesArtifact.getMainValuesQ(d)");
+    public List<NamedDouble> getMainValuesQ(double[] kms, Object pnpObject) {
+        if (kms.length > 1) {
+            log.error("How did you dare to give an array of lenght >1! " +
+                "DAS GEHT GARNICHT!!!! (we'll just take the first value)");
+        }
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
-        boolean atGauge = false;
         Gauge gauge = getGauge(kms[0]);
-        WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
+        River river = new RiverAccess((D4EArtifact)this).getRiver();
+        WstValueTable interpolator = WstValueTableFactory.getTable(river);
         Calculation c = new Calculation();
         double w_out[] = {0.0f};
         double q_out[] = {0.0f};
+        double pnp     = Double.NaN;
+
         if (gauge != null) {
             double gaugeStation = gauge.getStation().doubleValue();
-            atGauge = Math.abs(kms[0] - gaugeStation) < 1e-4;
             List<MainValue> orig = gauge.getMainValues();
+            if (pnpObject instanceof Number) {
+                pnp = Double.valueOf(pnpObject.toString());
+            }
+
             for (MainValue mv : orig) {
                 if (mv.getMainValue().getType().getName().equals("Q")) {
-                    if (atGauge) {
+                    if (pnpObject instanceof Number) {
                         q_out[0] = mv.getValue().doubleValue();
                     }
                     else {
@@ -405,68 +347,38 @@
 
     /**
      * Get a list of "Q" main values.
-     * @param atGauge whether is at gauge or needs interpolation.
      * @return list of Q main values.
      */
-    public List<NamedDouble> getMainValuesQ(boolean atGauge) {
-        log.debug("MainValuesArtifact.getMainValuesQ(b)");
+    public List<NamedDouble> getMainValuesQ(Object pnpObject) {
+        double kms[] = {getLocation()};
+        return getMainValuesQ(kms, pnpObject);
+    }
+
+
+    public List<NamedDouble> getMainValuesW(double[] kms, Object pnpObject) {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
-        Gauge gauge = getGauge();
-        WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
+        Gauge gauge = getGauge(kms[0]);
+        River river = new RiverAccess((D4EArtifact)this).getRiver();
+        WstValueTable interpolator = WstValueTableFactory.getTable(river);
         Calculation c = new Calculation();
         double w_out[] = {0.0f};
         double q_out[] = {0.0f};
-        double kms[] = {getLocation()};
+        double pnp     = Double.NaN;
+
         if (gauge != null) {
             double gaugeStation = gauge.getStation().doubleValue();
             List<MainValue> orig = gauge.getMainValues();
-            for (MainValue mv : orig) {
-                if (mv.getMainValue().getType().getName().equals("Q")) {
-                    if (atGauge) {
-                        q_out[0] = mv.getValue().doubleValue();
-                    }
-                    else {
-                        interpolator.interpolate(mv.getValue().doubleValue(),
-                            gaugeStation, kms, w_out, q_out, c);
-                    }
-                    filteredList.add(new NamedDouble(
-                                mv.getMainValue().getName(),
-                                q_out[0]
-                                ));
-                }
+            if (pnpObject instanceof Number) {
+                pnp = Double.valueOf(pnpObject.toString());
             }
-        }
-        return filteredList;
-    }
-
 
-    /** Get main values of km. */
-    public List<NamedDouble> getMainValuesW(double[] kms) {
-        List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
-        boolean atGauge = false;
-        double gaugeDatum = 0d;
-        Gauge gauge = getGauge(kms[0]);
-        if (gauge == null) {
-            return filteredList;
-        }
-        else if (Math.abs(kms[0] - gauge.getStation().doubleValue()) < 1e-4) {
-            atGauge = true;
-            gaugeDatum = gauge.getDatum().doubleValue();
-        }
-
-        WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
-        Calculation c = new Calculation();
-
-        double gaugeStation = gauge.getStation().doubleValue();
-        double w_out[] = {0.0f};
-        double q_out[] = {0.0f};
-        if (gauge != null) {
-            List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
-                if (atGauge) {
+                if (pnpObject instanceof Number) {
                     if (mv.getMainValue().getType().getName().equals("W")) {
-                        filteredList.add(new NamedDouble(mv.getMainValue().getName(),
-                                mv.getValue().doubleValue()));
+                        filteredList.add(new NamedDouble(
+                                mv.getMainValue().getName(),
+                                mv.getValue().doubleValue()/100 + pnp
+                            ));
                     }
                 } else
                 // We cannot interpolate the W values, so derive them
@@ -486,48 +398,12 @@
     }
 
 
-    public List<NamedDouble> getMainValuesW(boolean atGauge, double[] kms) {
-        List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
-        Gauge gauge = getGauge();
-        WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
-        Calculation c = new Calculation();
-
-        double w_out[] = {0.0f};
-        double q_out[] = {0.0f};
-        if (gauge != null) {
-            double gaugeStation = gauge.getStation().doubleValue();
-            List<MainValue> orig = gauge.getMainValues();
-            for (MainValue mv : orig) {
-                if (atGauge) {
-                    if (mv.getMainValue().getType().getName().equals("W")) {
-                        filteredList.add(new NamedDouble(mv.getMainValue().getName(),
-                                mv.getValue().doubleValue()));
-
-                    }
-                } else
-                // We cannot interpolate the W values, so derive them
-                // from given Q values.
-                if (mv.getMainValue().getType().getName().equals("Q")) {
-                    interpolator.interpolate(mv.getValue().doubleValue(),
-                            gaugeStation, kms, w_out, q_out, c);
-                    filteredList.add(new NamedDouble(
-                                "W(" + mv.getMainValue().getName() +")",
-                                w_out[0]
-                                ));
-                }
-            }
-        }
-        return filteredList;
-    }
-
-
     /**
      * Get a list of "W" main values.
-     * @param atGauge if true, do not interpolate
      * @return list of W main values.
      */
-    public List<NamedDouble> getMainValuesW(boolean atGauge) {
-        return getMainValuesW(atGauge, new double[] {getLocation()});
+    public List<NamedDouble> getMainValuesW(Object pnpObject) {
+        return getMainValuesW(new double[] {getLocation()}, pnpObject);
     }
 
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java	Fri Sep 26 09:44:48 2014 +0200
@@ -91,8 +91,6 @@
     private static final String [] INACTIVES = new String[] {
         LONGITUDINAL_Q,
         DURATION_Q,
-        HISTORICAL_DISCHARGE_MAINVALUES_W,
-        HISTORICAL_DISCHARGE_MAINVALUES_Q,
         STATIC_WQKMS_Q
     };
 
@@ -108,9 +106,7 @@
                     String   outputName
                 ) {
                     String fname = facet.getName();
-                    if ((fname.equals(COMPUTED_DISCHARGE_MAINVALUES_Q)
-                        || fname.equals(COMPUTED_DISCHARGE_MAINVALUES_W)
-                        || fname.equals(MAINVALUES_Q)
+                    if ((fname.equals(MAINVALUES_Q)
                         || fname.equals(MAINVALUES_W))
                         && outputName.equals("computed_discharge_curve"))
                     {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Fri Sep 26 09:44:48 2014 +0200
@@ -241,8 +241,6 @@
     String W_DIFFERENCES_FILTERED = "w_differences.filtered";
 
     String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q";
-    String COMPUTED_DISCHARGE_MAINVALUES_Q = "computed_discharge_curve.mainvalues.q";
-    String COMPUTED_DISCHARGE_MAINVALUES_W = "computed_discharge_curve.mainvalues.w";
 
     String MAINVALUES_Q = "mainvalues.q";
     String MAINVALUES_W = "mainvalues.w";
@@ -258,7 +256,6 @@
 
     String DURATION_W = "duration_curve.w";
     String DURATION_Q = "duration_curve.q";
-    String DURATION_MAINVALUES_Q = "duration_curve.mainvalues.q";
 
     String MANUALPOINTS = "manualpoints";
     String MANUALLINE = "manualline";
@@ -293,8 +290,6 @@
     String HISTORICAL_DISCHARGE_WQ_Q   = "historical_discharge.wq.q";
     String HISTORICAL_DISCHARGE_WQ_W   = "historical_discharge.wq.w";
     String HISTORICAL_DISCHARGE_WQ_CURVE = "historical_discharge.wq.curve";
-    String HISTORICAL_DISCHARGE_MAINVALUES_Q = "historical_discharge.mainvalues.q";
-    String HISTORICAL_DISCHARGE_MAINVALUES_W = "historical_discharge.mainvalues.w";
 
     String REFERENCE_CURVE            = "reference_curve";
     String REFERENCE_CURVE_NORMALIZED = "reference_curve_normalized";
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java	Fri Sep 26 09:44:48 2014 +0200
@@ -22,10 +22,13 @@
 import org.dive4elements.river.artifacts.MainValuesArtifact;
 import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
+import org.dive4elements.river.jfree.StickyAxisAnnotation.SimpleAxis;
 
 import org.dive4elements.river.exports.DurationCurveGenerator;
 import org.dive4elements.river.exports.fixings.FixChartGenerator;
 
+import static org.dive4elements.river.exports.injector.InjectorConstants.PNP;
+
 
 /**
  * Facet to show Main Q Values.
@@ -38,16 +41,11 @@
     /** Own log. */
     private static Logger log = Logger.getLogger(MainValuesQFacet.class);
 
-    /** Do we want MainValues at Gauge (not interpolated)? */
-    protected boolean isAtGauge;
-
-
     /** Trivial Constructor. */
-    public MainValuesQFacet(String name, String description, boolean atGauge) {
+    public MainValuesQFacet(String name, String description) {
         this.description = description;
         this.name        = name;
         this.index       = 0;
-        this.isAtGauge   = atGauge;
     }
 
     /**
@@ -82,23 +80,24 @@
     public Object getData(Artifact artifact, CallContext context) {
         MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact;
 
-        List<NamedDouble>          qs = mvArtifact.getMainValuesQ(isAtGauge);
+        List<NamedDouble>          qs = mvArtifact.getMainValuesQ(
+            context.getContextValue(PNP));
         List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
 
+        // Find whether a duration curve is on the blackboard.
         WQDay wqdays = null;
         List<DataProvider> providers = context.
             getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
         if (providers.size() < 1) {
-            log.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).
             Object xkm = context.getContextValue(FixChartGenerator.CURRENT_KM);
             if (xkm != null) {
                 Double ckm = (Double)xkm;
-                // Return linearly interpolated values, in m if not at gauge,
-                // in cm if at gauge.
-                qs = mvArtifact.getMainValuesQ(new double[] {ckm});
+                qs = mvArtifact.getMainValuesQ(
+                    new double[] {ckm},
+                    context.getContextValue(PNP));
             }
         }
         else {
@@ -110,39 +109,31 @@
 
         // Rather specific case, Q-Annotations at a maybe second yaxis.
         StickyAxisAnnotation annotation = null;
-        if (this.name.equals(DURATION_MAINVALUES_Q)) {
-            for (NamedDouble q: qs) {
-                if (Double.isNaN(q.getValue())) {
-                    log.warn("NaN MainValue " + q.getName());
-                    continue;
-                }
-                annotation =
-                    new StickyAxisAnnotation(
-                        q.getName(),
-                        (float) q.getValue(),
-                        StickyAxisAnnotation.SimpleAxis.Y_AXIS,
-                        DurationCurveGenerator.YAXIS.Q.idx);
-                xy.add(annotation);
-                if (wqdays != null) {
-                    setHitPoint(wqdays, annotation);
-                }
+
+        // defaults if not drawing a duration curve
+        SimpleAxis axis = SimpleAxis.X_AXIS;
+        int axisSymbol  = 0;
+
+        if (providers.size() >= 1) {
+            // for duration curve, overwrite previously given default
+            axis       = SimpleAxis.Y_AXIS;
+            axisSymbol = DurationCurveGenerator.YAXIS.Q.idx;
+        }
+
+        for (NamedDouble q: qs) {
+            if (Double.isNaN(q.getValue())) {
+                log.warn("NaN MainValue " + q.getName());
+                continue;
             }
-        }
-        else {
-            for (NamedDouble q: qs) {
-                if (Double.isNaN(q.getValue())) {
-                    log.warn("NaN MainValue " + q.getName());
-                    continue;
-                }
-                annotation =
-                    new StickyAxisAnnotation(
-                        q.getName(),
-                        (float) q.getValue(),
-                        StickyAxisAnnotation.SimpleAxis.X_AXIS);
-                xy.add(annotation);
-                if (wqdays != null) {
-                    setHitPoint(wqdays, annotation);
-                }
+            annotation =
+                new StickyAxisAnnotation(
+                    q.getName(),
+                    (float) q.getValue(),
+                    axis,
+                    axisSymbol);
+            xy.add(annotation);
+            if (wqdays != null) {
+                setHitPoint(wqdays, annotation);
             }
         }
 
@@ -157,7 +148,7 @@
     @Override
     public MainValuesQFacet deepCopy() {
         MainValuesQFacet copy = new MainValuesQFacet(this.name,
-            description, this.isAtGauge);
+            description);
         copy.set(this);
         return copy;
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java	Fri Sep 26 09:44:48 2014 +0200
@@ -24,6 +24,7 @@
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 import org.dive4elements.river.exports.fixings.FixChartGenerator;
 
+import static org.dive4elements.river.exports.injector.InjectorConstants.PNP;
 
 /**
  * Facet to show Main W Values.
@@ -35,15 +36,11 @@
     /** Own log. */
     private static Logger log = Logger.getLogger(MainValuesWFacet.class);
 
-    /** Do we want MainValues at Gauge (not interpolated)? */
-    protected boolean isAtGauge;
-
     /** Trivial Constructor. */
-    public MainValuesWFacet(String name, String description, boolean atGauge) {
+    public MainValuesWFacet(String name, String description) {
         this.description = description;
         this.name = name;
         this.index = 0;
-        this.isAtGauge = atGauge;
     }
 
 
@@ -79,7 +76,8 @@
     public Object getData(Artifact artifact, CallContext context) {
         MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact;
 
-        List<NamedDouble> ws = mvArtifact.getMainValuesW(isAtGauge);
+        List<NamedDouble> ws = mvArtifact.getMainValuesW(
+            context.getContextValue(PNP));
         List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
 
         // Find whether a duration curve is on the blackboard.
@@ -87,16 +85,18 @@
         List<DataProvider> providers = context.
             getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
         if (providers.size() < 1) {
-            log.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).
             Object xkm = context.getContextValue(FixChartGenerator.CURRENT_KM);
             if (xkm != null) {
                 Double ckm = (Double)xkm;
-                // Return linearly interpolated values, in m if not at gauge,
-                // in cm over datum if at gauge.
-                ws = mvArtifact.getMainValuesW(new double[] {ckm});
+                // Return linearly interpolated values. Always in m, as
+                // cm over datum ist represented by a second axis.
+                ws = mvArtifact.getMainValuesW(
+                    new double[] {ckm},
+                    context.getContextValue(PNP)
+                );
             }
         }
         else {
@@ -107,7 +107,6 @@
         }
 
         for (NamedDouble w: ws) {
-            log.debug("W Annotation at " + w.getValue() + " ("+w.getName()+")"+ wqdays);
             if (Double.isNaN(w.getValue())) {
                 log.warn("NaN MainValue " + w.getName());
                 continue;
@@ -134,7 +133,7 @@
     @Override
     public MainValuesWFacet deepCopy() {
         MainValuesWFacet copy = new MainValuesWFacet(this.name,
-            description, this.isAtGauge);
+            description);
         copy.set(this);
         return copy;
     }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java	Fri Sep 26 09:44:48 2014 +0200
@@ -197,11 +197,7 @@
                 attr,
                 visible);
         }
-        else if (name.equals(DURATION_MAINVALUES_Q)
-                || name.equals(MAINVALUES_Q)
-                || name.equals(COMPUTED_DISCHARGE_MAINVALUES_W)
-                || name.equals(MAINVALUES_W)
-        ) {
+        else if (name.equals(MAINVALUES_Q) || name.equals(MAINVALUES_W)) {
             doAnnotations(
                 (RiverAnnotation) artifactFacet.getData(context),
                 artifactFacet,
--- a/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java	Fri Sep 26 09:44:48 2014 +0200
@@ -136,10 +136,7 @@
             doPoints(artifactFacet.getData(context), artifactFacet, theme,
                 visible, YAXIS.W.idx);
         }
-        else if (name.equals(MAINVALUES_W) ||
-                 name.equals(MAINVALUES_Q) ||
-                 HISTORICAL_DISCHARGE_MAINVALUES_Q.equals(name) ||
-                 HISTORICAL_DISCHARGE_MAINVALUES_W.equals(name)) {
+        else if (name.equals(MAINVALUES_W) || name.equals(MAINVALUES_Q)) {
             doAnnotations((RiverAnnotation)
                 artifactFacet.getData(context), artifactFacet, theme, visible);
         }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java	Fri Sep 26 08:40:20 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java	Fri Sep 26 09:44:48 2014 +0200
@@ -242,15 +242,11 @@
     @Override
     public boolean canHandle(String facetType) {
         return STATIC_WQKMS_W.equals(facetType)
-            || COMPUTED_DISCHARGE_MAINVALUES_Q.equals(facetType)
             || MAINVALUES_Q.equals(facetType)
-            || COMPUTED_DISCHARGE_MAINVALUES_W.equals(facetType)
             || MAINVALUES_W.equals(facetType)
             || STATIC_W_INTERPOL.equals(facetType)
             || STATIC_WQ.equals(facetType)
             || STATIC_WQ_ANNOTATIONS.equals(facetType)
-            || HISTORICAL_DISCHARGE_MAINVALUES_Q.equals(facetType)
-            || HISTORICAL_DISCHARGE_MAINVALUES_W.equals(facetType)
             || HISTORICAL_DISCHARGE_WQ_W.equals(facetType)
             || HISTORICAL_DISCHARGE_WQ_Q.equals(facetType);
     }

http://dive4elements.wald.intevation.org