diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1847:8e5b4ea2851c

Minor cosmetics and let facets be inactive in duration curve diagrams. flys-artifacts/trunk@3191 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 09 Nov 2011 12:48:36 +0000
parents 4ee833095e75
children 7e7522c9e663
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Wed Nov 09 12:38:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Wed Nov 09 12:48:36 2011 +0000
@@ -122,13 +122,13 @@
         state = new StaticState(STATIC_STATE_NAME);
         List<Facet> fs = (List<Facet>) facets.get(STATIC_STATE_NAME);
 
-        DefaultOutput mainValuesOutput2 = new DefaultOutput(
+        DefaultOutput mainValuesOutput = new DefaultOutput(
             "computed_discharge_curve",
             "output.computed_discharge_curve", "image/png",
             fs,
             "chart");
 
-        state.getOutputs().add(mainValuesOutput2);
+        state.getOutputs().add(mainValuesOutput);
         return state;
     }
 
@@ -137,9 +137,16 @@
     protected void initialize(Artifact artifact, Object context, CallMeta meta) {
         logger.debug("MainValuesArtifact.initialize");
         WINFOArtifact winfo = (WINFOArtifact) artifact;
-        double location = FLYSUtils.getLocations(winfo)[0];
-        addData("location", new DefaultStateData("location", null, null,
+        double [] locations = FLYSUtils.getLocations(winfo);
+        if (locations != null) {
+            double location = locations[0];
+            addData("location", new DefaultStateData("location", null, null,
                     String.valueOf(location)));
+        }
+        else {
+            logger.warn("No location for mainvalues given.");
+        }
+        // TODO use importData
         addData("river", winfo.getData("river"));
     }
 
@@ -200,12 +207,14 @@
     protected Gauge getGauge() {
         River river = FLYSUtils.getRiver(this);
 
-        if (river == null) {
+        // TODO use helper to get location as double
+        String locationStr = getDataAsString("location");
+
+        if (river == null || locationStr == null) {
             return null;
         }
 
-        double location = Double.parseDouble(
-                getDataAsString("location"));
+        double location = Double.parseDouble(locationStr);
 
         return river.determineGaugeByPosition(location);
     }
@@ -216,8 +225,7 @@
      * @return the location.
      */
     public double getLocation() {
-        double location = Double.parseDouble(
-                (String)getData("location").getValue());
+        double location = Double.parseDouble(getDataAsString("location"));
         return location;
     }
 
@@ -261,6 +269,7 @@
         Gauge gauge = getGauge();
         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};
@@ -304,7 +313,8 @@
            + "/"
            + facetName);
 
-        if (outputName.equals("computed_discharge_curve")) {
+        if (outputName.equals("computed_discharge_curve")
+            || outputName.equals("duration_curve")) {
             return 0;
         }
         else {

http://dive4elements.wald.intevation.org