changeset 6757:e0ac1b19dfcc

issue1435: Tolerate missing measurement values in QualityMeasurements.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 06 Aug 2013 16:03:56 +0200
parents 9cc0b03656fb
children 67182bde34cd
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurement.java
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurement.java	Tue Aug 06 12:26:21 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurement.java	Tue Aug 06 16:03:56 2013 +0200
@@ -11,8 +11,11 @@
 import java.util.Date;
 import java.util.Map;
 
+import org.apache.log4j.Logger;
 
+/** A measurement of the bed quality, serving different diameter at given km. */
 public class QualityMeasurement {
+    private static Logger logger = Logger.getLogger(QualityMeasurements.class);
 
     private double              km;
     private Date                date;
@@ -61,8 +64,16 @@
         this.charDiameter = charDiameter;
     }
 
+    /**
+     * Get the stored diameter for given key (e.g. d10).
+     * @return NaN if no data found in this measurement.
+     */
     public double getDiameter(String key) {
-        return charDiameter.get(key);
+        Double diameter = charDiameter.get(key);
+        if (diameter == null) {
+            logger.warn("No Diameter at km " + km + " for " + key);
+        }
+        return (diameter != null) ? diameter : Double.NaN;
     }
 
     public void setDiameter(String key, double value) {

http://dive4elements.wald.intevation.org