[Dive4elements-commits] [PATCH] Use 'W [cm]' as CSV header if discharge table is at a gauge

Wald Commits scm-commit at wald.intevation.org
Fri May 10 17:14:13 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1368198850 -7200
# Node ID b740f0c4179edb5238d27013b25a0b3cc52e4e7f
# Parent  f33d717aae5ccd4027c17c106e2c4d3aed8586eb
Use 'W [cm]' as CSV header if discharge table is at a gauge.

diff -r f33d717aae5c -r b740f0c4179e artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java	Fri May 10 16:24:38 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java	Fri May 10 17:14:10 2013 +0200
@@ -39,10 +39,14 @@
 
 import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.model.CalculationResult;
+import org.dive4elements.river.artifacts.model.GaugeFinder;
+import org.dive4elements.river.artifacts.model.GaugeFinderFactory;
+import org.dive4elements.river.artifacts.model.GaugesFactory;
 import org.dive4elements.river.artifacts.model.WQKms;
 import org.dive4elements.river.artifacts.model.WKmsJRDataSource;
 import org.dive4elements.river.artifacts.resources.Resources;
 
+import org.dive4elements.river.model.Gauge;
 import org.dive4elements.river.utils.RiverUtils;
 import org.dive4elements.river.utils.Formatter;
 
@@ -127,9 +131,20 @@
         logger.debug("ComputedDischargeCurveExporter.writeCSVHeader");
 
         String unit = RiverUtils.getRiver((D4EArtifact) master).getWstUnit().getName();
-
+        RangeAccess access = new RangeAccess((D4EArtifact)master, context);
+        double[] km = access.getLocations();
+        String header =
+            msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit });
+        if (km != null) {
+            List<Gauge>gauges = GaugesFactory.getGauges(access.getRiver());
+            for (Gauge g : gauges) {
+                if (g.getStation().doubleValue() == km[0]) {
+                    header = "W [cm]";
+                }
+            }
+        }
         writer.writeNext(new String[] {
-            msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit }),
+            header,
             msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER)
         });
     }


More information about the Dive4elements-commits mailing list