[PATCH] issue1465: Assume that a "0" measurement for total sediment load is

Wald Commits scm-commit at wald.intevation.org
Mon Sep 16 09:41:45 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1379317948 -7200
# Node ID acb63fd3c8d39aeaef9c76a000f07bb106cabe11
# Parent  b9633d6ce57e16f3f5172ef1ee3d4ad0be00d775
issue1465: Assume that a "0" measurement for total sediment load is
unlikely enough that we will not encounter it. Replace "0" total
values with " ".

diff -r b9633d6ce57e -r acb63fd3c8d3 artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Mon Sep 16 09:17:33 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Mon Sep 16 09:52:28 2013 +0200
@@ -107,6 +107,8 @@
         }
     }
 
+
+    /** Return space when val is NaN, apply NumberFormat otherwise. */
     private String numberToString(NumberFormat valf, double val) {
         if (Double.isNaN(val)) {
             return " ";
@@ -114,6 +116,14 @@
         return valf.format(val);
     }
 
+    /** Return space when val is NaN or zero, apply NumberFormat otherwise. */
+    private String nonZeroToString(NumberFormat valf, double val) {
+        if (Double.isNaN(val) || val == 0d) {
+            return " ";
+        }
+        return valf.format(val);
+    }
+
     /** Write a line. */
     private void writeRecord(
         CSVWriter writer,
@@ -133,7 +143,7 @@
             numberToString(valf, fraction.getSand()),
             numberToString(valf, fraction.getFineMiddle()),
             numberToString(valf, fraction.getCoarse()),
-            numberToString(valf, fraction.getTotal())
+            nonZeroToString(valf, fraction.getTotal())
         });
     }
 


More information about the Dive4elements-commits mailing list