[Dive4elements-commits] [PATCH] Use Double.NaN for missing values in middle bedheight calculation and write empty strings in csv export

Wald Commits scm-commit at wald.intevation.org
Mon Jun 17 15:37:49 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1371476246 -7200
# Node ID 2c7a16d59f67c7dbad1b3b925530fbd0f65b85e9
# Parent  876c797c280510c982fcc5ddc4326cc4f429e495
Use Double.NaN for missing values in middle bedheight calculation and write empty strings in csv export.

diff -r 876c797c2805 -r 2c7a16d59f67 artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java	Mon Jun 17 14:30:00 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java	Mon Jun 17 15:37:26 2013 +0200
@@ -157,11 +157,17 @@
 
         for (BedHeightSingleValue value: values) {
             if (value.getHeight() != null) {
+                double uncert = value.getUncertainty() != null ?
+                    value.getUncertainty().doubleValue() : Double.NaN;
+                double sounding = value.getSoundingWidth() != null ?
+                    value.getSoundingWidth().doubleValue() : Double.NaN;
+                double gap = value.getDataGap() != null ?
+                    value.getDataGap().doubleValue() : Double.NaN;
                 data.addAll(value.getStation().doubleValue(),
                     value.getHeight().doubleValue(),
-                    value.getUncertainty().doubleValue(),
-                    value.getSoundingWidth().doubleValue(),
-                    value.getDataGap().doubleValue(),
+                    uncert,
+                    sounding,
+                    gap,
                     value.getWidth().doubleValue(),
                     false);
              }
diff -r 876c797c2805 -r 2c7a16d59f67 artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java	Mon Jun 17 14:30:00 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java	Mon Jun 17 15:37:26 2013 +0200
@@ -131,13 +131,19 @@
                 int end   = data.getEndYear();
 
                 if (start == end) {
+                    String uncert = !Double.isNaN(data.getUncertainty(i)) ?
+                        uncertF.format(data.getUncertainty(i)) : "";
+                    String gap = !Double.isNaN(data.getDataGap(i)) ?
+                        gapF.format(data.getDataGap(i)) + "%" : "";
+                    String sound = !Double.isNaN(data.getSoundingWidth(i)) ?
+                        soundF.format(data.getSoundingWidth(i)) : "";
                     writer.writeNext(new String[] {
                         kmF.format(data.getKM(i)),
                         data.getDescription(),
                         heightF.format(data.getMiddleHeight(i)),
-                        uncertF.format(data.getUncertainty(i)),
-                        gapF.format(data.getDataGap(i)) + "%",
-                        soundF.format(data.getSoundingWidth(i)),
+                        uncert,
+                        gap,
+                        sound,
                         widthF.format(data.getWidth(i)),
                         RiverUtils.getLocationDescription(flys, data.getKM(i)),
                     });


More information about the Dive4elements-commits mailing list