[PATCH] Added diff pair column to CSV export of bed height differences. TODO: same for PDF, adjust client
Wald Commits
scm-commit at wald.intevation.org
Wed Jun 4 12:54:58 CEST 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1401879208 -7200
# Node ID 76b5add4f268d912b86c430e76b2395ae69f8123
# Parent 06aca4e889b92f104e9766b4bd2e63683b50c734
Added diff pair column to CSV export of bed height differences. TODO: same for PDF, adjust client.
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffEpochResult.java
--- 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;
+ }
}
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java
--- 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 :
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDifferencesResult.java
--- 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();
}
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java
--- 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()]));
}
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/resources/messages.properties
--- 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
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/resources/messages_de.properties
--- 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
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/resources/messages_de_DE.properties
--- 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
diff -r 06aca4e889b9 -r 76b5add4f268 artifacts/src/main/resources/messages_en.properties
--- 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
More information about the Dive4Elements-commits
mailing list