changeset 1101:82798c992975

Interpolate Q main values, generate interpolated W main values on the fly from Q main values. flys-artifacts/trunk@2604 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 29 Aug 2011 09:07:55 +0000
parents 29c67a76ad5d
children 7bd514eb4b2c
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java
diffstat 2 files changed, 44 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Aug 29 09:04:48 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Aug 29 09:07:55 2011 +0000
@@ -1,3 +1,14 @@
+2011-08-29  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Interpolate Q main values, generate interpolated W main values on the fly from
+	Q main values.
+
+	* src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java:
+	  (getGaugeDatum): removed, obsolete
+	  (getLocation): new, gets location
+	  Use WstValueTable to look up interpolated Qs of MainValues. In absence of
+	  the same functionality for Ws, generate W Main Values from Q Main Values.
+
 2011-08-29  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Use new helper class FLYSUtils, minor refactorization.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Mon Aug 29 09:04:48 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Mon Aug 29 09:07:55 2011 +0000
@@ -21,11 +21,15 @@
 import de.intevation.flys.model.MainValue;
 import de.intevation.flys.model.River;
 
+import de.intevation.flys.artifacts.model.Calculation;
 import de.intevation.flys.artifacts.model.MainValuesQFacet;
 import de.intevation.flys.artifacts.model.MainValuesWFacet;
 import de.intevation.flys.artifacts.model.NamedDouble;
-import de.intevation.flys.artifacts.model.RiverFactory;
+import de.intevation.flys.artifacts.model.WstValueTable;
+import de.intevation.flys.artifacts.model.WstValueTableFactory;
+
 import de.intevation.flys.artifacts.states.StaticState;
+
 import de.intevation.flys.utils.FLYSUtils;
 
 
@@ -173,13 +177,13 @@
 
 
     /**
-     * Get datum of Gauge.
-     * @return datum of gauge.
+     * Get current location.
+     * @return the location.
      */
-    public double getGaugeDatum() {
-        Gauge gauge = getGauge();
-        if (gauge == null) { return 0.0f; }
-        return gauge.getDatum().doubleValue();
+    public double getLocation() {
+        double location = Double.parseDouble(
+                (String)getData("location").getValue());
+        return location;
     }
 
 
@@ -190,13 +194,21 @@
     public List<NamedDouble> getMainValuesQ() {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
+        WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this));
+        Calculation c = new Calculation();
+        double w_out[] = {0.0f};
+        double q_out[] = {0.0f};
+        double kms[] = {getLocation()};
+        double gaugeStation = gauge.getStation().doubleValue();
         if (gauge != null) {
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
                 if (mv.getMainValue().getType().getName().equals("Q")) {
+                    interpolator.interpolate(mv.getValue().doubleValue(),
+                            gaugeStation, kms, w_out, q_out, c);
                     filteredList.add(new NamedDouble(
                                 mv.getMainValue().getName(),
-                                mv.getValue().doubleValue()
+                                q_out[0]
                                 ));
                 }
             }
@@ -212,14 +224,23 @@
     public List<NamedDouble> getMainValuesW() {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
-        double datum = gauge.getDatum().doubleValue();
+        WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this));
+        Calculation c = new Calculation();
+        double gaugeStation = gauge.getStation().doubleValue();
+        double w_out[] = {0.0f};
+        double q_out[] = {0.0f};
+        double kms[] = {getLocation()};
         if (gauge != null) {
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
-                if (mv.getMainValue().getType().getName().equals("W")) {
+                // 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(
-                                mv.getMainValue().getName(),
-                                mv.getValue().doubleValue()/100.f + datum
+                                "W(" + mv.getMainValue().getName() +")",
+                                w_out[0]
                                 ));
                 }
             }

http://dive4elements.wald.intevation.org