Mercurial > dive4elements > river
changeset 7018:acb63fd3c8d3
issue1465: Assume that a "0" measurement for total sediment load is
unlikely enough that we will not encounter it. Replace "0" total
values with " ".
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 16 Sep 2013 09:52:28 +0200 (2013-09-16) |
parents | b9633d6ce57e |
children | a2d61401bd92 |
files | artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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()) }); }