changeset 5981:b740f0c4179e 3.0.3

Use 'W [cm]' as CSV header if discharge table is at a gauge.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 10 May 2013 17:14:10 +0200
parents f33d717aae5c
children 9ba54ae49cf4
files artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)
         });
     }

http://dive4elements.wald.intevation.org