changeset 1906:0de18085948a

Respect position for computed discharge curve when interpolating WQs for e.g. for fixations. flys-artifacts/trunk@3266 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 16 Nov 2011 10:25:16 +0000 (2011-11-16)
parents d025009fec73
children 6c7fdfd262ac
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java
diffstat 2 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Nov 16 09:43:58 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Nov 16 10:25:16 2011 +0000
@@ -1,3 +1,9 @@
+2011-11-16  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java:
+	  Get ld_locations not locations data item to determine km.
+	  (getDataAsDouble): New helper function to get data item as double.
+
 2011-11-16  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* doc/conf/meta-data.xml: Recommend fixations for computed discharge
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java	Wed Nov 16 09:43:58 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java	Wed Nov 16 10:25:16 2011 +0000
@@ -146,9 +146,7 @@
         logger.debug("WQKmsInterpolArtifact.initialize");
         WINFOArtifact winfo = (WINFOArtifact) artifact;
         importData(winfo, "river");
-        importData(winfo, "location");
-        logger.debug("WQKmsInterpolArtifact is @(location) " +
-             this.getDataAsString("location"));
+        importData(winfo, "ld_locations");
     }
 
 
@@ -175,8 +173,8 @@
         // @TODO we might have to give column position for certain datasets.
         //            getDataAsInt("col_pos"));
 
-        // TODO respect given km.
-        double [][] vs = interpolator.interpolateWQColumnwise(44.51);
+        double [][] vs = interpolator.interpolateWQColumnwise(
+            getDataAsDouble("ld_locations"));
 
         for (int x = 0; x < vs[1].length; x++) {
             logger.debug("getWQAtKm: Q/W " + vs[0][x] + " / " + vs[1][x]);
@@ -202,6 +200,21 @@
 
 
     /**
+     * Get a DataItem casted to double (0 if fails).
+     */
+    public double getDataAsDouble(String dataName) {
+        String val = getDataAsString(dataName);
+        try {
+            return Double.valueOf(val);
+        }
+        catch (NumberFormatException e) {
+            logger.warn("Could not get data " + dataName + " as double", e);
+            return 0;
+        }
+    }
+
+
+    /**
      * Get the "current" state (there is but one).
      * @param cc ignored.
      * @return the "current" (only possible) state.

http://dive4elements.wald.intevation.org