changeset 403:1ed48e2ddc1b

Added an OutGenerator to create discharge longitudinal section charts. flys-artifacts/trunk@1844 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 06 May 2011 14:20:26 +0000
parents eb22ffe4d74c
children 349c9bcdd917
files flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java
diffstat 2 files changed, 130 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/conf.xml	Fri May 06 14:19:27 2011 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Fri May 06 14:20:26 2011 +0000
@@ -53,6 +53,7 @@
         <output-generator name="computed_discharge_curve">de.intevation.flys.exports.ComputedDischargeCurveGenerator</output-generator>
         <output-generator name="longitudinal_section">de.intevation.flys.exports.LongitudinalSectionGenerator</output-generator>
         <output-generator name="duration_curve">de.intevation.flys.exports.DurationCurveGenerator</output-generator>
+        <output-generator name="discharge_longitudinal_section">de.intevation.flys.exports.DischargeLongitudinalSectionGenerator</output-generator>
         <output-generator name="waterlevel_export">de.intevation.flys.exports.WaterlevelExporter</output-generator>
         <output-generator name="durationcurve_export">de.intevation.flys.exports.DurationCurveExporter</output-generator>
         <output-generator name="computed_dischargecurve_export">de.intevation.flys.exports.ComputedDischargeCurveExporter</output-generator>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Fri May 06 14:20:26 2011 +0000
@@ -0,0 +1,129 @@
+package de.intevation.flys.exports;
+
+import org.apache.log4j.Logger;
+
+import org.jfree.data.xy.XYSeries;
+
+import org.w3c.dom.Document;
+
+import de.intevation.artifacts.Artifact;
+
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.WQCKms;
+import de.intevation.flys.artifacts.model.WQKms;
+
+
+/**
+ * An OutGenerator that generates discharge longitudinal section curves.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DischargeLongitudinalSectionGenerator
+extends      LongitudinalSectionGenerator
+{
+    private static Logger logger =
+        Logger.getLogger(DischargeLongitudinalSectionGenerator.class);
+
+
+    /** The facet for Ws.*/
+    public static final String FACET_W = "discharge_longitudinal_section.w";
+
+    /** The facet for Qs.*/
+    public static final String FACET_Q = "discharge_longitudinal_section.q";
+
+
+
+    @Override
+    public void doOut(Artifact artifact, String facet, Document attr) {
+        logger.debug("DischargeLongitudinalSectionGenerator.doOut");
+
+        if (facet != null && facet.equals(FACET_W)) {
+            doWOut(getDischargeLongitudinalSectionData(artifact));
+        }
+        else if (facet != null && facet.equals(FACET_Q)) {
+            doQOut(getDischargeLongitudinalSectionData(artifact));
+        }
+        else {
+            logger.warn("Unknown facet name: " + facet);
+            return;
+        }
+    }
+
+
+    protected WQKms[] getDischargeLongitudinalSectionData(Artifact artifact) {
+        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
+        return winfoArtifact.getDischargeLongitudinalSectionData();
+    }
+
+
+    /**
+     * This method adds new Series for the wqkms objects. If there are instances
+     * of WQCKms in this array, there is a further curve that displays the
+     * corrected W values.
+     *
+     * @param wqkms An array of WQKms objects to be displayed.
+     */
+    protected void doWOut(WQKms[] wqkms) {
+        logger.debug("LongitudinalSectionGenerator.doWOut");
+
+        int idx = 0;
+        for (WQKms tmp: wqkms) {
+            if (tmp instanceof WQCKms) {
+                doCorrectedWOut((WQCKms) tmp);
+            }
+
+            doWOut(tmp);
+        }
+    }
+
+
+    /**
+     * Adds a new series for the W curve.
+     *
+     * @param wqkms The object that contains the W values.
+     */
+    protected void doWOut(WQKms wqkms) {
+        logger.debug("DischargeLongitudinalSectionGenerator.doWOut");
+
+        // TODO CREATE CORRECT SERIES NAME
+        XYSeries series = new XYSeries("W");
+
+        double[] target = new double[4];
+        int      size   = wqkms.size();
+
+        for (int i = 0; i < size; i++) {
+            target = wqkms.get(i, target);
+
+            series.add(target[2], target[0]);
+        }
+
+        w.addSeries(series);
+    }
+
+
+    /**
+     * Adds a new series for the corrected W curve.
+     *
+     * @param wqckms The object that contains the corrected W values.
+     */
+    protected void doCorrectedWOut(WQCKms wqckms) {
+        logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut");
+
+        // TODO CREATE CORRECT SERIES NAME
+        XYSeries series = new XYSeries("Korrigiert");
+
+        double[] target = new double[4];
+        int      size   = wqckms.size();
+
+        for (int i = 0; i < size; i++) {
+            target = wqckms.get(i, target);
+
+            series.add(target[2], target[3]);
+        }
+
+        if (series.getItemCount() > 0) {
+            w.addSeries(series);
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org