[Dive4elements-commits] [PATCH 2 of 2] Merged

Wald Commits scm-commit at wald.intevation.org
Thu Jan 31 16:00:31 CET 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1359644421 -3600
# Node ID 04c68af455347704bc453f296e4ee45c3c7ec6db
# Parent  450840751f1b829b9e27c0a085d78e836e86305a
# Parent  65059ad920c62c8d698db17c47d3d7e1a9adbf8c
Merged.

diff -r 450840751f1b -r 04c68af45534 flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Thu Jan 31 14:45:38 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Thu Jan 31 16:00:21 2013 +0100
@@ -92,16 +92,33 @@
         double[] kms = rangeAccess.getLocations();
 
         Gauge gauge = river.determineGaugeByPosition(kms[0]);
-        TimeInterval interval =
-            gauge.fetchMasterDischargeTable().getTimeInterval();
-        at.write(
-            new OutputStreamWriter(out, DEFAULT_ENCODING),
-            context.getMeta(),
-            river.getName(),
-            kms[0],
-            gauge.getName(),
-            gauge.getDatum(),
-            interval.getStartTime());
+        if (kms[0] == gauge.getStation().doubleValue() + 1e-4) {
+            // at gauge.
+            TimeInterval interval =
+                gauge.fetchMasterDischargeTable().getTimeInterval();
+            at.write(
+                new OutputStreamWriter(out, DEFAULT_ENCODING),
+                context.getMeta(),
+                river.getName(),
+                kms[0],
+                gauge.getName(),
+                gauge.getDatum(),
+                interval.getStartTime(),
+                100d);
+        }
+        else {
+            // at km
+            at.write(
+                new OutputStreamWriter(out),
+                context.getMeta(),
+                river.getName(),
+                kms[0],
+                null,
+                null,
+                null,
+                0d);
+        }
+
     }
 
 
diff -r 450840751f1b -r 04c68af45534 flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java	Thu Jan 31 14:45:38 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java	Thu Jan 31 16:00:21 2013 +0100
@@ -35,6 +35,9 @@
     public static final String I18N_AT_HEADER =
         "export.discharge.curve.at.header";
 
+    public static final String I18N_AT_GAUGE_HEADER =
+        "export.discharge.curve.at.gauge.header";
+
     public static final String EMPTY = "         ";
 
     protected double minW;
@@ -109,7 +112,7 @@
     }
 
 
-    protected static void printHeader(
+    protected static void printGaugeHeader(
         PrintWriter out,
         CallMeta    callMeta,
         String      river,
@@ -121,12 +124,26 @@
         DateFormat f = DateFormat.getDateInstance();
         out.print(Resources.getMsg(
             callMeta,
-            I18N_AT_HEADER,
-            I18N_AT_HEADER,
+            I18N_AT_GAUGE_HEADER,
+            I18N_AT_GAUGE_HEADER,
             new Object[] { river, gName, f.format(date), datum } ));
         out.print("\r\n");
     }
 
+    protected static void printHeader(
+        PrintWriter out,
+        CallMeta    callMeta,
+        String      river,
+        double      km
+    ) {
+        DateFormat f = DateFormat.getDateInstance();
+        out.print(Resources.getMsg(
+            callMeta,
+            I18N_AT_HEADER,
+            I18N_AT_HEADER,
+            new Object[] { river, km } ));
+        out.print("\r\n");
+    }
 
     public void write(
         Writer writer,
@@ -135,14 +152,20 @@
         double km,
         String gName,
         BigDecimal datum,
-        Date date)
+        Date date,
+        double scale)
     throws IOException
     {
         PrintWriter out = new PrintWriter(writer);
 
         // a header is required, because the desktop version of FLYS will skip
         // the first row.
-        printHeader(out, meta, river, km, gName, datum, date);
+        if (gName != null) {
+            printGaugeHeader(out, meta, river, km, gName, datum, date);
+        }
+        else {
+            printHeader(out, meta, river, km);
+        }
 
         double rest = (minW * 100.0) % 10.0;
 
@@ -156,7 +179,7 @@
         int col = 0;
         for (double w = startW; w <= maxW; w += 0.01) {
             if (col == 0) {
-                out.printf(Locale.US, "%8d", (int)Math.round(w));
+                out.printf(Locale.US, "%8d", (int)Math.round(w * scale));
             }
 
             if (w < minW) {
diff -r 450840751f1b -r 04c68af45534 flys-artifacts/src/main/resources/messages.properties
--- a/flys-artifacts/src/main/resources/messages.properties	Thu Jan 31 14:45:38 2013 +0100
+++ b/flys-artifacts/src/main/resources/messages.properties	Thu Jan 31 16:00:21 2013 +0100
@@ -325,6 +325,7 @@
 export.discharge.longitudinal.section.csv.header.cw = W corr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
 export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1}
+export.discharge.curve.at.gauge.header = Discharge Table for {1}/{0} since {2} PNP[NN+m] = {3}
 export.historical.discharge.csv.header.timerange = Timerange
 export.historical.discharge.csv.header.waterlevel = Waterlevel [cm]
 export.historical.discharge.csv.header.discharge = Discharge [m\u00b3/s]
diff -r 450840751f1b -r 04c68af45534 flys-artifacts/src/main/resources/messages_de.properties
--- a/flys-artifacts/src/main/resources/messages_de.properties	Thu Jan 31 14:45:38 2013 +0100
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Thu Jan 31 16:00:21 2013 +0100
@@ -314,7 +314,8 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W korr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
-export.discharge.curve.at.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[NN+m] = {3}
+export.discharge.curve.at.header = Berechnete Abflusstafel f\u00fcr {0}, km {1}
+export.discharge.curve.at.gauge.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[NN+m] = {3}
 export.historical.discharge.csv.header.timerange = Zeitraum
 export.historical.discharge.csv.header.waterlevel = Wasserstand [cm]
 export.historical.discharge.csv.header.discharge = Abfluss [m\u00b3/s]
diff -r 450840751f1b -r 04c68af45534 flys-artifacts/src/main/resources/messages_de_DE.properties
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Thu Jan 31 14:45:38 2013 +0100
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Thu Jan 31 16:00:21 2013 +0100
@@ -323,7 +323,8 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W korr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
-export.discharge.curve.at.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[NN+m] = {3}
+export.discharge.curve.at.gauge.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[NN+m] = {3}
+export.discharge.curve.at.header = Berechnete Abflusstafel f\u00fcr {0}, km {1}
 export.historical.discharge.csv.header.timerange = Zeitraum
 export.historical.discharge.csv.header.waterlevel = Wasserstand [cm]
 export.historical.discharge.csv.header.discharge = Abfluss [m\u00b3/s]
diff -r 450840751f1b -r 04c68af45534 flys-artifacts/src/main/resources/messages_en.properties
--- a/flys-artifacts/src/main/resources/messages_en.properties	Thu Jan 31 14:45:38 2013 +0100
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Thu Jan 31 16:00:21 2013 +0100
@@ -326,7 +326,8 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W corr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
-export.discharge.curve.at.header = Dischargetable for {1}/{0} since {2} Datum[NN+m] = {3}
+export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1}
+export.discharge.curve.at.gauge.header = Dischargetable for {1}/{0} since {2} Datum[NN+m] = {3}
 export.historical.discharge.csv.header.timerange = Timerange
 export.historical.discharge.csv.header.waterlevel = Waterlevel [cm]
 export.historical.discharge.csv.header.discharge = Discharge [m\u00b3/s]


More information about the Dive4elements-commits mailing list