changeset 7913:76b5add4f268

Added diff pair column to CSV export of bed height differences. TODO: same for PDF, adjust client.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 04 Jun 2014 12:53:28 +0200
parents 06aca4e889b9
children db1a2b14c32d
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffEpochResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDifferencesResult.java artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties artifacts/src/main/resources/messages_de_DE.properties artifacts/src/main/resources/messages_en.properties
diffstat 8 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffEpochResult.java	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffEpochResult.java	Wed Jun 04 12:53:28 2014 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.artifacts.model.minfo;
 
+import java.util.Calendar;
 import java.util.Date;
 
 import gnu.trove.TDoubleArrayList;
@@ -52,4 +53,20 @@
     public Date getEnd() {
         return this.end;
     }
+
+    private static final int extractYear(Date date) {
+        if (date == null) {
+            return 0;
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        return c.get(Calendar.YEAR);
+    }
+
+    @Override
+    public String getDiffDescription() {
+        int y1 = extractYear(start);
+        int y2 = extractYear(end);
+        return y1 + " - " + y2;
+    }
 }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java	Wed Jun 04 12:53:28 2014 +0200
@@ -159,5 +159,10 @@
             bedHeights.toNativeArray()
         };
     }
+
+    @Override
+    public String getDiffDescription() {
+        return nameFirst + " - " + nameSecond;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDifferencesResult.java	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDifferencesResult.java	Wed Jun 04 12:53:28 2014 +0200
@@ -13,8 +13,8 @@
 import java.io.Serializable;
 
 
-public class BedDifferencesResult
-implements Serializable
+public abstract class BedDifferencesResult
+implements            Serializable
 {
 
     protected TDoubleArrayList kms;
@@ -93,4 +93,6 @@
             height2.toNativeArray()
         };
     }
+
+    public abstract String getDiffDescription();
 }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java	Wed Jun 04 12:53:28 2014 +0200
@@ -11,7 +11,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.text.NumberFormat;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
@@ -56,6 +56,9 @@
     private static final String CSV_HEADER_DIFF =
         "export.minfo.beddifference.diff";
 
+    private static final String CSV_HEADER_DIFF_PAIR =
+        "export.minfo.beddifference.diff.pair";
+
     private static final String CSV_HEADER_MORPH1 =
         "export.minfo.beddifference.morph1";
 
@@ -86,6 +89,7 @@
         for (BedDifferencesResult result : results) {
             if (result instanceof BedDiffYearResult) {
                 BedDiffYearResult yResult = (BedDiffYearResult) result;
+                String desc = result.getDiffDescription();
                 double[][] kms = yResult.getDifferencesData();
                 double[][] morph1 = yResult.getMorphWidth1Data();
                 double[][] morph2 = yResult.getMorphWidth2Data();
@@ -94,15 +98,18 @@
                         kmf.format(kms[0][j]),
                         mf.format(kms[1][j]),
                         mf.format(morph1[1][j]),
-                        mf.format(morph2[1][j])});
+                        mf.format(morph2[1][j]),
+                        desc });
                 }
             }
             else {
                 double[][] kms = result.getDifferencesData();
+                String desc = result.getDiffDescription();
                 for (int j = 0; j < kms[0].length; j++) {
                     writer.writeNext(new String[] {
                         kmf.format(kms[0][j]),
-                        mf.format(kms[1][j])});
+                        mf.format(kms[1][j]),
+                        desc });
                 }
             }
         }
@@ -157,7 +164,7 @@
     protected void writeCSVHeader(CSVWriter writer) {
         logger.debug("writeCSVHeader()");
 
-        List<String> header = new LinkedList<String>();
+        List<String> header = new ArrayList<String>();
         if (results != null)  {
             header.add(msg(CSV_HEADER_KM, "km"));
             header.add(msg(CSV_HEADER_DIFF, "cm"));
@@ -166,6 +173,7 @@
                 header.add(msg(CSV_HEADER_MORPH1, "morph width minuend [m]"));
                 header.add(msg(CSV_HEADER_MORPH2, "morph width subtrahend [m]"));
             }
+            header.add(msg(CSV_HEADER_DIFF_PAIR, "difference pair"));
         }
         writer.writeNext(header.toArray(new String[header.size()]));
     }
--- a/artifacts/src/main/resources/messages.properties	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/resources/messages.properties	Wed Jun 04 12:53:28 2014 +0200
@@ -451,6 +451,7 @@
 export.minfo.bedquality.bed_sub = Bed Diameter Sublayer
 export.minfo.beddifference.km = km
 export.minfo.beddifference.diff = Bedheight Difference [cm]
+export.minfo.beddifference.diff.pair = Difference pair
 export.minfo.beddifference.pdf.file = /jasper/beddifference_en.jasper
 export.minfo.beddifference.pdf.title = Bedheight Difference
 export.minfo.beddifference.pdf.mode = Bedheight Difference
--- a/artifacts/src/main/resources/messages_de.properties	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Wed Jun 04 12:53:28 2014 +0200
@@ -453,6 +453,7 @@
 export.minfo.bedquality.bed_sub = Sohldurchmesser Unterschicht [mm]
 export.minfo.beddifference.km = Fluss-km
 export.minfo.beddifference.diff = Sohlh\u00f6hendifferenz [cm]
+export.minfo.beddifference.diff.pair = Differenzenpaar
 export.minfo.beddifference.pdf.file = /jasper/beddifference.jasper
 export.minfo.beddifference.pdf.title = Sohlh\u00f6hendifferenz
 export.minfo.beddifference.pdf.mode = Sohlh\u00f6hendifferenz
--- a/artifacts/src/main/resources/messages_de_DE.properties	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Wed Jun 04 12:53:28 2014 +0200
@@ -449,6 +449,7 @@
 export.minfo.bedquality.bed_sub = Sohldurchmesser Unterschicht [mm]
 export.minfo.beddifference.km = Fluss-km
 export.minfo.beddifference.diff = Sohlh\u00f6hendifferenz [cm]
+export.minfo.beddifference.diff.pair = Differenzenpaar
 export.minfo.beddifference.pdf.file = /jasper/beddifference.jasper
 export.minfo.beddifference.pdf.title = Sohlh\u00f6hendifferenz
 export.minfo.beddifference.pdf.mode = Sohlh\u00f6hendifferenz
--- a/artifacts/src/main/resources/messages_en.properties	Wed Jun 04 12:22:01 2014 +0200
+++ b/artifacts/src/main/resources/messages_en.properties	Wed Jun 04 12:53:28 2014 +0200
@@ -455,6 +455,7 @@
 export.minfo.bedquality.bed_sub = Bed Diameter Sublayer [mm]
 export.minfo.beddifference.km = km
 export.minfo.beddifference.diff = Bedheight Difference [cm]
+export.minfo.beddifference.diff.pair = Difference pair
 export.minfo.beddifference.pdf.file = /jasper/beddifference_en.jasper
 export.minfo.beddifference.pdf.title = Bedheight Difference
 export.minfo.beddifference.pdf.mode = Bedheight Difference

http://dive4elements.wald.intevation.org