changeset 6984:77f48c104d23

Backed out changeset 6b9402377d07
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 11 Sep 2013 09:46:11 +0200
parents 93e7f947f6fa
children 1faf543e267c
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
diffstat 1 files changed, 4 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Tue Sep 10 17:48:48 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Wed Sep 11 09:46:11 2013 +0200
@@ -13,7 +13,6 @@
 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;
@@ -487,46 +486,19 @@
         return new SedimentLoad();
     }
 
-
-    /**
-     * Returns range of matching measurementstation.
-     * If no direct match is found, the measurement-station with
-     * the next lower station is taken - but only if km is still in
-     * its range.
-     *
-     * The end of the range is the beginning of the next range (next as in
-     * next greater station), or if it is the last, by its own ranges end.
-     *
-     * @param stations Map of station to measurementstation (attention:
-     *                 the range of a m.station does not necessarily
-     *                 begin at the registered station).
-     * @param km       The station for which to find a measurementstation.
-     *
-     * @return The validity range of a station (interereted as described above
-     *         for given km or null if none found.
-     */
     protected static Range findMeasurementStationRange(
         TreeMap<Double, MeasurementStation> stations,
         double 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)) {
+        MeasurementStation station = stations.get(km);
+        if (station == null) {
             return null;
         }
 
         double endKm;
 
-        Map.Entry<Double, MeasurementStation> ceilingEntry =
-            stations.ceilingEntry(km + 0.1d);
-
-        if (ceilingEntry != null) {
-            MeasurementStation nextStation = ceilingEntry.getValue();
+        if (stations.ceilingEntry(km + 0.1d) != null) {
+            MeasurementStation nextStation = stations.ceilingEntry(km + 0.1d).getValue();
             endKm = nextStation.getRange().getA().doubleValue();
         }
         else {
@@ -539,7 +511,6 @@
             endKm);
     }
 
-
     /**
      * Run query with grain parameter set to fraction, feed result into
      * load. Create load if null.

http://dive4elements.wald.intevation.org