changeset 4302:ce10b846bc86

ExtremeCompute: Generate LS-Facets.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 29 Oct 2012 13:46:39 +0100
parents 1f304cb5729b
children d65cf8e40230
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java
diffstat 1 files changed, 43 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java	Mon Oct 29 13:46:19 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java	Mon Oct 29 13:46:39 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,6 +29,7 @@
 /** State in which to deliver extreme value analysis result. */
 public class ExtremeCompute
 extends      DefaultState
+implements   FacetTypes
 {
     /** Private logger. */
     private static Logger logger = Logger.getLogger(ExtremeCompute.class);
@@ -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