[PATCH] issue1465: Prepare SedimentLoadExporter to show "-" for NaN-values
Wald Commits
scm-commit at wald.intevation.org
Fri Sep 13 12:20:47 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1379068242 -7200
# Node ID d584100063dd60bbfe8e4054faca36164f936662
# Parent 5fe8c64b48d4cfdac5fcf24bb0c16fe042155202
issue1465: Prepare SedimentLoadExporter to show "-" for NaN-values.
Unfortunately, the calculation breaks at other places if NaN-values are seen.
diff -r 5fe8c64b48d4 -r d584100063dd artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Fri Sep 13 12:02:40 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Fri Sep 13 12:30:42 2013 +0200
@@ -107,6 +107,13 @@
}
}
+ private String numberToString(NumberFormat valf, double val) {
+ if (Double.isNaN(val)) {
+ return "-";
+ }
+ return valf.format(val);
+ }
+
/** Write a line. */
private void writeRecord(
CSVWriter writer,
@@ -120,13 +127,13 @@
writer.writeNext(new String[] {
kmf.format(km),
years,
- valf.format(fraction.getSuspSediment()),
- valf.format(fraction.getSuspSand()),
- valf.format(fraction.getSuspSandBed()),
- valf.format(fraction.getSand()),
- valf.format(fraction.getFineMiddle()),
- valf.format(fraction.getCoarse()),
- valf.format(fraction.getTotal())
+ numberToString(valf, fraction.getSuspSediment()),
+ numberToString(valf, fraction.getSuspSand()),
+ numberToString(valf, fraction.getSuspSandBed()),
+ numberToString(valf, fraction.getSand()),
+ numberToString(valf, fraction.getFineMiddle()),
+ numberToString(valf, fraction.getCoarse()),
+ numberToString(valf, fraction.getTotal())
});
}
More information about the Dive4elements-commits
mailing list