diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1957:3b08b8aacfb0

Fix flys/issue423, do not interpolate main values at gauge. flys-artifacts/trunk@3357 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 06 Dec 2011 08:26:24 +0000
parents 7e7522c9e663
children 024d986b4f5b
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Mon Dec 05 10:40:14 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Tue Dec 06 08:26:24 2011 +0000
@@ -83,25 +83,29 @@
             Resources.getMsg(
                 callMeta,
                 "facet.discharge_curves.mainvalues.q",
-                "facet.discharge_curves.mainvalues.q"));
+                "facet.discharge_curves.mainvalues.q"),
+            false);
         Facet qfacet2 = new MainValuesQFacet(
             MAINVALUES_Q,
             Resources.getMsg(
                 callMeta,
                 "facet.discharge_curves.mainvalues.q",
-                "facet.discharge_curves.mainvalues.q"));
+                "facet.discharge_curves.mainvalues.q"),
+            true);
         Facet wfacet1 = new MainValuesWFacet(
             COMPUTED_DISCHARGE_MAINVALUES_W,
             Resources.getMsg(
                 callMeta,
                 "facet.discharge_curves.mainvalues.w",
-                "facet.discharge_curves.mainvalues.w"));
+                "facet.discharge_curves.mainvalues.w"),
+            false);
         Facet wfacet2 = new MainValuesWFacet(
             MAINVALUES_W,
             Resources.getMsg(
                 callMeta,
                 "facet.discharge_curves.mainvalues.w",
-                "facet.discharge_curves.mainvalues.w"));
+                "facet.discharge_curves.mainvalues.w"),
+            true);
 
         List<Facet> fs = new ArrayList<Facet>();
         fs.add(qfacet1);
@@ -233,7 +237,7 @@
      * Get a list of "Q" main values.
      * @return list of Q main values.
      */
-    public List<NamedDouble> getMainValuesQ() {
+    public List<NamedDouble> getMainValuesQ(boolean atGauge) {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
         WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this));
@@ -246,8 +250,13 @@
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
                 if (mv.getMainValue().getType().getName().equals("Q")) {
-                    interpolator.interpolate(mv.getValue().doubleValue(),
+                    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]
@@ -261,9 +270,10 @@
 
     /**
      * Get a list of "W" main values.
+     * @param atGauge if true, do not interpolate
      * @return list of W main values.
      */
-    public List<NamedDouble> getMainValuesW() {
+    public List<NamedDouble> getMainValuesW(boolean atGauge) {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
         WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this));
@@ -276,6 +286,13 @@
         if (gauge != null) {
             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")) {

http://dive4elements.wald.intevation.org