Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 6970:7be97faf5848
flys/issue1235: Same kicks against a few inconsistencies and bugs in the calculation of sediment loads. I believe it _do_not_ delivers the right results.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 05 Sep 2013 17:15:04 +0200 |
parents | c137f5028591 |
children | 77f48c104d23 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Thu Sep 05 15:47:24 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Thu Sep 05 17:15:04 2013 +0200 @@ -13,6 +13,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.TreeMap; import net.sf.ehcache.Cache; @@ -508,15 +509,24 @@ TreeMap<Double, MeasurementStation> stations, double km ) { - MeasurementStation station = stations.floorEntry(km).getValue(); - if (station == null || !station.getRange().contains(km)) { + Map.Entry<Double, MeasurementStation> entry = stations.floorEntry(km); + if (entry == null) { + return null; + } + MeasurementStation station = entry.getValue(); + if (station == null + || station.getRange() == null + || !station.getRange().contains(km)) { return null; } double endKm; - if (stations.ceilingEntry(km + 0.1d) != null) { - MeasurementStation nextStation = stations.ceilingEntry(km + 0.1d).getValue(); + Map.Entry<Double, MeasurementStation> ceilingEntry = + stations.ceilingEntry(km + 0.1d); + + if (ceilingEntry != null) { + MeasurementStation nextStation = ceilingEntry.getValue(); endKm = nextStation.getRange().getA().doubleValue(); } else {