[PATCH 1 of 7] SedimentLoadExporter: Minor refac. Determine a displayed string

Wald Commits scm-commit at wald.intevation.org
Thu Sep 5 15:37:46 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1378374518 -7200
# Node ID aa1d681ee6eb4c75bbc09b5f322769cef57a9f03
# Parent  234b1a3b527d4b9d1bf58f2e2375181e0c22b0e2
SedimentLoadExporter: Minor refac. Determine a displayed string
only when necessary.

diff -r 234b1a3b527d -r aa1d681ee6eb artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Wed Sep 04 10:53:53 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Thu Sep 05 11:48:38 2013 +0200
@@ -95,19 +95,26 @@
         writeCSVHeader(writer);
 
         for (SedimentLoadResult result: results) {
+            String years = (toYear == 0)
+                    ? result.getStartYear()+ " "
+                    : result.getStartYear() + "-" + result.getEndYear();
             SedimentLoad load = result.getLoad();
             // Put load.getName()+load.getDescription()}); somewhere?
             for (double km: new TreeSet<Double>(load.getKms())) {
                 SedimentLoadFraction fraction = load.getFraction(km);
-                writeRecord(writer, km, result.getStartYear(), result.getEndYear(), fraction);
+                writeRecord(writer, km, years, fraction);
             }
         }
     }
 
     /** Write a line. */
-    private void writeRecord(CSVWriter writer, double km, int fromYear, int toYear, SedimentLoadFraction fraction) {
+    private void writeRecord(
+        CSVWriter writer,
+        double km,
+        String years,
+        SedimentLoadFraction fraction
+    ) {
         // year, total, susp sed, susp sandbed suspsand, sand, finemiddle, coarse
-        String years = (toYear == 0) ? fromYear+"" : fromYear + "-" + toYear;
         NumberFormat kmf = Formatter.getCalculationKm(context.getMeta());
         NumberFormat valf = Formatter.getFormatter(context.getMeta(), 0, 2);
         writer.writeNext(new String[] {


More information about the Dive4elements-commits mailing list