changeset 628:51b69bca4560

ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation. flys-artifacts/trunk@1993 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 24 May 2011 12:37:45 +0000
parents 833290f16f09
children 65e4e42b4b03
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java
diffstat 4 files changed, 55 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 24 11:27:37 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 24 12:37:45 2011 +0000
@@ -1,3 +1,16 @@
+2011-05-23  Ingo Weinzierl <ingo@intevation.de>
+
+	  ISSUE-85 (part III/III)
+
+	* src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java:
+	  Added a static function that returns the kilometer values (double[])
+	  from locations input (whitespace separated double values).
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Adapted
+	  the getKms() method. It will now return a computed array of kilometers
+	  if we had inserted a range, or it will return the inserted kilometers if
+	  we had inserted locations.
+
 2011-05-24	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java:
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Tue May 24 11:27:37 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Tue May 24 12:37:45 2011 +0000
@@ -54,6 +54,8 @@
         </state>
 
         <state id="state.winfo.location_distance" description="state.winfo.location_distance" state="de.intevation.flys.artifacts.states.LocationDistanceSelect">
+            <data name="ld_mode" type="String" />
+            <data name="ld_locations" type="Double[]" />
             <data name="ld_from" type="Double" />
             <data name="ld_to" type="Double" />
             <data name="ld_step" type="Double" />
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Tue May 24 11:27:37 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Tue May 24 12:37:45 2011 +0000
@@ -39,6 +39,7 @@
 import de.intevation.flys.artifacts.model.DischargeTables;
 import de.intevation.flys.artifacts.model.RiverFactory;
 import de.intevation.flys.artifacts.states.DefaultState;
+import de.intevation.flys.artifacts.states.LocationDistanceSelect;
 
 
 /**
@@ -475,7 +476,7 @@
 
         String value = (String) mode.getValue();
 
-        return value.equals("range");
+        return value.equals("distance");
     }
 
 
@@ -593,8 +594,14 @@
      * @return the selected kms.
      */
     public double[] getKms() {
-        double[] distance = getDistance();
-        return getKms(distance);
+        if (isRange()) {
+            double[] distance = getDistance();
+            return getKms(distance);
+
+        }
+        else {
+            return LocationDistanceSelect.getLocations(this);
+        }
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Tue May 24 11:27:37 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Tue May 24 12:37:45 2011 +0000
@@ -1,9 +1,14 @@
 package de.intevation.flys.artifacts.states;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Element;
 
+import gnu.trove.TDoubleArrayList;
+
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
@@ -261,5 +266,30 @@
 
         return minmax;
     }
+
+
+    public static double[] getLocations(FLYSArtifact flys) {
+        StateData data  = flys.getData("ld_locations");
+        String    value = data != null ? (String) data.getValue() : null;
+
+        if (value == null || value.length() == 0) {
+            logger.warn("No location data given.");
+            return null;
+        }
+
+        String[]         splitted = value.split(" ");
+        TDoubleArrayList values   = new TDoubleArrayList();
+
+        for (String split: splitted) {
+            try {
+                values.add(Double.valueOf(split));
+            }
+            catch (NumberFormatException nfe) {
+                logger.warn(nfe, nfe);
+            }
+        }
+
+        return values.toNativeArray();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org