changeset 2065:2f5628f0de0e

Part 2 of #125: add gaugename and Q description based on the selected WQ mode. flys-artifacts/trunk@3559 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 02 Jan 2012 09:46:39 +0000
parents ca8997aa683e
children 2b6a0de47379
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java
diffstat 3 files changed, 65 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jan 02 08:51:45 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jan 02 09:46:39 2012 +0000
@@ -1,3 +1,15 @@
+2012-01-02  Ingo Weinzierl <ingo@intevation.de>
+
+	PART II of flys/issue125 (W-INFO: Wasserspiegellagenberechnung / tabellarische Berechnungsausgabe)
+
+	* src/main/java/de/intevation/flys/exports/WaterlevelExporter.java: Add the
+	  named main value of a Q and the name of the gauge used for the calculation
+	  if the WQ mode is "W at gauge" or "Q at gauge".
+
+	* src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java:
+	  Adapted the method signatures that have been modified in
+	  WaterlevelExporter.
+
 2012-01-02  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/StyledAreaSeriesCollection.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Mon Jan 02 08:51:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Mon Jan 02 09:46:39 2012 +0000
@@ -50,7 +50,7 @@
 
 
     @Override
-    protected void writeCSVHeader(CSVWriter writer) {
+    protected void writeCSVHeader(CSVWriter writer, boolean atGauge) {
         logger.info("WaterlevelExporter.writeCSVHeader");
 
         writer.writeNext(new String[] {
@@ -62,7 +62,7 @@
     }
 
     @Override
-    protected void wQKms2CSV(CSVWriter writer, WQKms wqkms) {
+    protected void wQKms2CSV(CSVWriter writer, WQKms wqkms, boolean atGauge) {
         logger.debug("WaterlevelExporter.wQKms2CSV");
 
         int      size   = wqkms.size();
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Mon Jan 02 08:51:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Mon Jan 02 09:46:39 2012 +0000
@@ -28,6 +28,7 @@
 import de.intevation.flys.artifacts.resources.Resources;
 
 import de.intevation.flys.utils.FLYSUtils;
+import de.intevation.flys.utils.FLYSUtils.WQ_MODE;
 import de.intevation.flys.utils.Formatter;
 
 
@@ -190,12 +191,15 @@
     protected void writeCSVData(CSVWriter writer) {
         logger.info("WaterlevelExporter.writeData");
 
+        WQ_MODE mode    = FLYSUtils.getWQMode((FLYSArtifact)master);
+        boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE;
+
         writeCSVMeta(writer);
-        writeCSVHeader(writer);
+        writeCSVHeader(writer, atGauge);
 
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
-                wQKms2CSV(writer, wqkms);
+                wQKms2CSV(writer, wqkms, atGauge);
             }
         }
     }
@@ -310,21 +314,31 @@
     }
 
 
-    protected void writeCSVHeader(CSVWriter writer) {
+    protected void writeCSVHeader(CSVWriter writer, boolean atGauge) {
         logger.info("WaterlevelExporter.writeCSVHeader");
 
-        writer.writeNext(new String[] {
-            msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER),
-            msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER),
-            msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER),
-            msg(CSV_Q_DESC_HEADER, DEFAULT_CSV_Q_DESC_HEADER),
-            msg(CSV_LOCATION_HEADER, DEFAULT_CSV_LOCATION_HEADER),
-            msg(CSV_GAUGE_HEADER, DEFAULT_CSV_GAUGE_HEADER)
-        });
+        if (atGauge) {
+            writer.writeNext(new String[] {
+                msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER),
+                msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER),
+                msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER),
+                msg(CSV_Q_DESC_HEADER, DEFAULT_CSV_Q_DESC_HEADER),
+                msg(CSV_LOCATION_HEADER, DEFAULT_CSV_LOCATION_HEADER),
+                msg(CSV_GAUGE_HEADER, DEFAULT_CSV_GAUGE_HEADER)
+            });
+        }
+        else {
+            writer.writeNext(new String[] {
+                msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER),
+                msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER),
+                msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER),
+                msg(CSV_LOCATION_HEADER, DEFAULT_CSV_LOCATION_HEADER)
+            });
+        }
     }
 
 
-    protected void wQKms2CSV(CSVWriter writer, WQKms wqkms) {
+    protected void wQKms2CSV(CSVWriter writer, WQKms wqkms, boolean atGauge) {
         logger.debug("WaterlevelExporter.wQKms2CSV");
 
         NumberFormat kmf = getKmFormatter();
@@ -334,19 +348,35 @@
         int      size   = wqkms.size();
         double[] result = new double[3];
 
-        FLYSArtifact flys = (FLYSArtifact) master;
+        FLYSArtifact flys  = (FLYSArtifact) master;
+        String       gauge = FLYSUtils.getGaugename(flys);
+        String       desc  = "";
+
+        if (flys instanceof WINFOArtifact) {
+            desc = getColumnTitle((WINFOArtifact)flys, wqkms);
+        }
 
         for (int i = 0; i < size; i ++) {
             result = wqkms.get(i, result);
 
-            writer.writeNext(new String[] {
-                kmf.format(result[2]),
-                wf.format(result[0]),
-                qf.format(result[1]),
-                "", // Bezeichnung
-                FLYSUtils.getLocationDescription(flys, result[2]),
-                "" // Bezugspegel
-            });
+            if (atGauge) {
+                writer.writeNext(new String[] {
+                    kmf.format(result[2]),
+                    wf.format(result[0]),
+                    qf.format(result[1]),
+                    desc,
+                    FLYSUtils.getLocationDescription(flys, result[2]),
+                    gauge
+                });
+            }
+            else {
+                writer.writeNext(new String[] {
+                    kmf.format(result[2]),
+                    wf.format(result[0]),
+                    qf.format(result[1]),
+                    FLYSUtils.getLocationDescription(flys, result[2])
+                });
+            }
         }
     }
 

http://dive4elements.wald.intevation.org