# HG changeset patch # User Felix Wolfsteller # Date 1375797836 -7200 # Node ID e0ac1b19dfcc94550e8884c14f784a8fb131c7ac # Parent 9cc0b03656fb6eee1a35a1bc50a975319e3c9e27 issue1435: Tolerate missing measurement values in QualityMeasurements. diff -r 9cc0b03656fb -r e0ac1b19dfcc artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurement.java --- 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) {