changeset 7007:d584100063dd

issue1465: Prepare SedimentLoadExporter to show "-" for NaN-values. Unfortunately, the calculation breaks at other places if NaN-values are seen.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 13 Sep 2013 12:30:42 +0200
parents 5fe8c64b48d4
children 0e7c667018fc
files artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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())
         });
     }
 

http://dive4elements.wald.intevation.org