changeset 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 a5f87f8dbe57
children 82cefa3f954f
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java
diffstat 4 files changed, 60 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Dec 05 10:40:14 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Dec 06 08:26:24 2011 +0000
@@ -1,3 +1,20 @@
+2011-12-06	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Fix flys/issue423 (Diagramm: Hauptwerte bei Abflusskurve am Pegel
+	werden an Y-Achse nicht angezeigt) - show not "raw" (vs interpolated)
+	values at Gauge.
+
+	* src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java:
+	  Add parameterization to let facet know whether to fetch data at
+	  Gauges or at Artifacts position.
+
+	* src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java:
+	  Let the MainValueFacets know whether to ask for interpolated
+	  MainValues; (do not interpolate for Gauges Main Values).
+	  (getMainValuesQ, getMainValuesW): Added parameter to control
+					    interpolation.
+
 2011-12-05  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/MapfileGenerator.java: Modified
@@ -14,6 +31,7 @@
 	  not. In addition, the scenario parameter used by WSPLGEN is now set
 	  correctly.
 
+>>>>>>> .r3356
 2011-12-05	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Allow longitudinal_section.q facets in wdiff states output.
--- 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")) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java	Mon Dec 05 10:40:14 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java	Tue Dec 06 08:26:24 2011 +0000
@@ -22,11 +22,15 @@
 extends      DefaultFacet
 implements   FacetTypes {
 
+    /** Do we want MainValues at Gauge (not interpolated)? */
+    protected boolean isAtGauge;
+
     /** Trivial Constructor. */
-    public MainValuesQFacet(String name, String description) {
+    public MainValuesQFacet(String name, String description, boolean atGauge) {
         this.description = description;
         this.name = name;
-        index = 0;
+        this.index = 0;
+        this.isAtGauge = atGauge;
     }
 
 
@@ -42,7 +46,7 @@
     public Object getData(Artifact artifact, CallContext context) {
         MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact;
 
-        List<NamedDouble>      qs = mvArtifact.getMainValuesQ();
+        List<NamedDouble>      qs = mvArtifact.getMainValuesQ(isAtGauge);
         List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
 
         for (NamedDouble q: qs) {
@@ -62,7 +66,8 @@
      */
     @Override
     public MainValuesQFacet deepCopy() {
-        MainValuesQFacet copy = new MainValuesQFacet(this.name, description);
+        MainValuesQFacet copy = new MainValuesQFacet(this.name,
+            description, this.isAtGauge);
         copy.set(this);
         return copy;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java	Mon Dec 05 10:40:14 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java	Tue Dec 06 08:26:24 2011 +0000
@@ -22,11 +22,15 @@
 extends      DefaultFacet
 implements   FacetTypes {
 
+    /** Do we want MainValues at Gauge (not interpolated)? */
+    protected boolean isAtGauge;
+
     /** Trivial Constructor. */
-    public MainValuesWFacet(String name, String description) {
+    public MainValuesWFacet(String name, String description, boolean atGauge) {
         this.description = description;
         this.name = name;
-        index = 0;
+        this.index = 0;
+        this.isAtGauge = atGauge;
     }
 
 
@@ -42,7 +46,7 @@
     public Object getData(Artifact artifact, CallContext context) {
         MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact;
 
-        List<NamedDouble>      ws = mvArtifact.getMainValuesW();
+        List<NamedDouble>      ws = mvArtifact.getMainValuesW(isAtGauge);
         List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
 
         for (NamedDouble w: ws) {
@@ -50,7 +54,6 @@
                 w.getName(),
                 (float) w.getValue(),
                 StickyAxisAnnotation.SimpleAxis.Y_AXIS));
-
         }
 
         return new FLYSAnnotation(description, xy);
@@ -63,7 +66,8 @@
      */
     @Override
     public MainValuesWFacet deepCopy() {
-        MainValuesWFacet copy = new MainValuesWFacet(this.name, description);
+        MainValuesWFacet copy = new MainValuesWFacet(this.name,
+            description, this.isAtGauge);
         copy.set(this);
         return copy;
     }

http://dive4elements.wald.intevation.org