changeset 8339:d6e71158222a

Look for gauge if no pnp is set in the context and return w in cm if at gauge.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 29 Sep 2014 15:49:04 +0200
parents ac7cb15e1946
children 8679875f2c09
files artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java
diffstat 1 files changed, 26 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Fri Sep 26 18:23:45 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Mon Sep 29 15:49:04 2014 +0200
@@ -44,6 +44,7 @@
 
 import org.dive4elements.river.artifacts.states.StaticState;
 import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.exports.injector.InjectorConstants;
 
 
 /**
@@ -373,6 +374,9 @@
             }
 
             for (MainValue mv : orig) {
+                Gauge g = river.determineGaugeByStation(
+                    kms[0] - InjectorConstants.GAUGE_EPSILON,
+                    kms[0] + InjectorConstants.GAUGE_EPSILON);
                 if (pnpObject instanceof Number) {
                     if (mv.getMainValue().getType().getName().equals("W")) {
                         filteredList.add(new NamedDouble(
@@ -380,17 +384,29 @@
                                 mv.getValue().doubleValue()/100 + pnp
                             ));
                     }
-                } 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);
+                }
+                else if (!(pnpObject instanceof Number) &&
+                    g != null
+                ) {
+                    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]
-                                ));
+                        filteredList.add(new NamedDouble(
+                                    "W(" + mv.getMainValue().getName() +")",
+                                    w_out[0]
+                                    ));
+                    }
                 }
             }
         }

http://dive4elements.wald.intevation.org