changeset 407:9eb5f0c8fe7f

Added a CSV exporter for the discharge longitudinal section computation. flys-artifacts/trunk@1858 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 09 May 2011 09:55:47 +0000
parents 663aa18bee7f
children fc3ac59c3c8b
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java
diffstat 4 files changed, 75 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sat May 07 21:34:02 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon May 09 09:55:47 2011 +0000
@@ -1,3 +1,14 @@
+2011-05-09  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java:
+	  New. This OutGenerator exports the data of a discharge longitudinal
+	  section computation.
+
+	* doc/conf/conf.xml: Added the DischargeLongitudinalSectionExporter.
+
+	* doc/conf/artifacts/winfo.xml: Added the exporter with CSV facet to the
+	  discharge_longitudinal_section state.
+
 2011-05-07	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/math/BackJumpCorrector.java:
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Sat May 07 21:34:02 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Mon May 09 09:55:47 2011 +0000
@@ -175,6 +175,11 @@
                         <facet name="discharge_longitudinal_section.q"/>
                     </facets>
                 </outputmode>
+                <outputmode name="discharge_longitudinal_section_export" description="output.discharge_longitudinal_section_export" mime-type="text/plain">
+                    <facets>
+                        <facet name="csv" description="facet.discharge_longitudinal_section_export.csv" />
+                    </facets>
+                </outputmode>
             </outputmodes>
         </state>
 
--- a/flys-artifacts/doc/conf/conf.xml	Sat May 07 21:34:02 2011 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Mon May 09 09:55:47 2011 +0000
@@ -57,6 +57,7 @@
         <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>
+        <output-generator name="discharge_longitudinal_section_export">de.intevation.flys.exports.DischargeLongitudinalSectionExporter</output-generator>
     </output-generators>
 
     <rest-server>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Mon May 09 09:55:47 2011 +0000
@@ -0,0 +1,58 @@
+package de.intevation.flys.exports;
+
+import org.apache.log4j.Logger;
+
+import au.com.bytecode.opencsv.CSVWriter;
+
+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;
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DischargeLongitudinalSectionExporter extends WaterlevelExporter {
+
+    /** The logger used in this exporter.*/
+    private static Logger logger =
+        Logger.getLogger(DischargeLongitudinalSectionExporter.class);
+
+
+    @Override
+    protected void addData(Artifact artifact) {
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+        WQKms[]       wqkms = winfo.getDischargeLongitudinalSectionData();
+
+        logger.debug("Got " + wqkms != null ? wqkms.length : 0 + " WQKms obj.");
+
+        data.add(wqkms);
+    }
+
+
+    @Override
+    protected void wQKms2CSV(CSVWriter writer, WQKms wqkms) {
+        logger.debug("WaterlevelExporter.wQKms2CSV");
+
+        int      size   = wqkms.size();
+        double[] result = new double[4];
+
+        for (int i = 0; i < size; i ++) {
+            result = wqkms.get(i, result);
+
+            String wc = "";
+            if (wqkms instanceof WQCKms) {
+                wc = Double.toString(result[3]);
+            }
+
+            writer.writeNext(new String[] {
+                Double.toString(result[2]),
+                Double.toString(result[0]),
+                wc,
+                Double.toString(result[1])
+            });
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org