changeset 449:9814d4808410

flys/issue69: Connected calculation with the UI flys-artifacts/trunk@1941 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 18 May 2011 09:11:10 +0000
parents 88d9e1d75d64
children c8bb38115290
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java
diffstat 2 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed May 18 09:02:50 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed May 18 09:11:10 2011 +0000
@@ -1,3 +1,13 @@
+2011-05-19	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+    Work on flys/issue69
+
+    * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java:
+      Use new logic to calculate "Wasserstand/Wasserspiegellage".
+      Compared to desktop FLYS are the results are structurally right 
+      but a bit off in the positions after the decimal points.
+      Maybe a result of the interpolation? Need to debug this.
+
 2011-05-18  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed May 18 09:02:50 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed May 18 09:11:10 2011 +0000
@@ -2,6 +2,7 @@
 
 import java.util.List;
 import java.util.Vector;
+import java.util.ArrayList;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -311,23 +312,24 @@
         logger.info("WINFOArtifact.computeWaterlevelData");
 
         WQKms[] wqkms = new WQKms[qs.length];
-        for (int i = 0; i < wqkms.length; i++) {
-            wqkms[i] = new WQKms(kms.length);
-        }
-
-        double [] interpolatedW = new double[qs.length];
 
-        for (double km: kms) {
-            wst.interpolateW(km, qs, interpolatedW);
+        ArrayList<WQKms> results = new ArrayList<WQKms>();
 
-            // TODO Modify the interpolation to return a better formed data
-            // structure.
-            for (int i = 0; i < interpolatedW.length; i++) {
-                wqkms[i].add(interpolatedW[i], qs[i], km);
+        for (int i = 0; i < qs.length; i++) {
+            double [] oqs = new double[kms.length];
+            double [] ows = new double[kms.length];
+            int referenceIndex = 0; // TODO: Make depend on the flow direction
+            WstValueTable.QPosition qPosition =
+                wst.interpolate(qs[i], referenceIndex, kms, ows, oqs);
+            if (qPosition != null) {
+                results.add(new WQKms(kms, oqs, ows));
+            }
+            else {
+                logger.warn("interpolation failed for q = " + qs[i]);
             }
         }
 
-        return wqkms;
+        return results.toArray(new WQKms[results.size()]);
     }
 
 

http://dive4elements.wald.intevation.org