changeset 4304:45f793826a43

Merged
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 29 Oct 2012 13:48:46 +0100
parents d65cf8e40230 (diff) 9ddc1d9b035a (current diff)
children 8c51c43e59ca 2e8e00026059
files
diffstat 2 files changed, 49 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Mon Oct 29 13:17:04 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Mon Oct 29 13:48:46 2012 +0100
@@ -6,6 +6,7 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.math.Linear;
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import de.intevation.flys.artifacts.model.extreme.ExtremeResult;
 
 import org.apache.log4j.Logger;
 
@@ -35,7 +36,9 @@
     }
 
     protected WQKms [] getWQKms(CalculationResult res) {
-        return (WQKms [])res.getData();
+        if (res.getData() instanceof ExtremeResult)
+            return ((ExtremeResult) res.getData()).getWQKms();
+        return (WQKms []) res.getData();
     }
 
     /**
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java	Mon Oct 29 13:17:04 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java	Mon Oct 29 13:48:46 2012 +0100
@@ -8,13 +8,20 @@
 
 import de.intevation.flys.artifacts.access.ExtremeAccess;
 
+import de.intevation.flys.artifacts.model.Calculation;
 import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.ReportFacet;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+import de.intevation.flys.artifacts.model.WQKms;
 
 import de.intevation.flys.artifacts.model.extreme.ExtremeCalculation;
+import de.intevation.flys.artifacts.model.extreme.ExtremeResult;
 
 import de.intevation.flys.artifacts.states.DefaultState;
 
+import de.intevation.flys.utils.FLYSUtils;
+
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -22,9 +29,10 @@
 /** State in which to deliver extreme value analysis result. */
 public class ExtremeCompute
 extends      DefaultState
+implements   FacetTypes
 {
     /** Private logger. */
-    private static Logger log = Logger.getLogger(ExtremeCompute.class);
+    private static Logger logger = Logger.getLogger(ExtremeCompute.class);
 
     public ExtremeCompute() {
     }
@@ -37,7 +45,7 @@
         List<Facet>  facets,
         Object       old
     ) {
-        log.debug("ExtremeCompute.computeAdvance");
+        logger.debug("ExtremeCompute.computeAdvance");
 
         CalculationResult res;
 
@@ -59,7 +67,41 @@
             facets.add(new ReportFacet());
         }
 
-        // TODO: Add more facets.
+        ExtremeResult eres = (ExtremeResult) res.getData();
+        WQKms [] wqkms = (WQKms []) eres.getWQKms();
+
+        if (wqkms == null) {
+            logger.error("No computation result!");
+        }
+
+        for (int i = 0; i < wqkms.length; i++) {
+            String name = wqkms[i].getName();
+
+            // Ext.Calc has wqkmsName(i)
+            String nameW = "WW";//TODO: FLYSUtils.createWspWTitle(artifact, context, name);
+            String nameQ = "QQ";//FLYSUtils.createWspQTitle(artifact, context, name);
+
+            // Hotfix for theme names. Themes with the same name cause problems
+            // aggregating chart legend items.
+            if (i > 0 && name.equals(wqkms[i - 1].getName())) {
+                nameW += "; Q=" + wqkms[i].get(0, new double[3])[1];
+                nameQ += " = " + wqkms[i].get(0, new double[3])[1];
+            }
+
+            Facet w = new WaterlevelFacet(
+                i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash);
+            Facet q = new WaterlevelFacet(
+                i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash);
+
+            // TODO add more facets like:
+            // csv, data, pdf wst facet
+            // furthermore, waterlevel
+            //facets.add(new CrossSectionWaterLineFacet(i, nameW));
+
+            facets.add(w);
+            facets.add(q);
+        }
+
 
         return res;
     }

http://dive4elements.wald.intevation.org