changeset 6343:588e99129883

issue1235: Values are valid until next measurements station range start.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 14 Jun 2013 17:11:33 +0200
parents b8cd8e2d0c35
children bc28de00e423
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java
diffstat 1 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java	Fri Jun 14 17:09:25 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java	Fri Jun 14 17:11:33 2013 +0200
@@ -120,16 +120,24 @@
         int i = 0;
         for (Map.Entry<Double, Double> kmLoad: sortedKmLoad.entrySet()) {
             boolean matchFound = false;
-            // For now, ignore overlaps like (B> next A)
-            for (MeasurementStation station: stations) {
-                if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON ||
-                    station.getRange().containsTolerant(kmLoad.getKey())) {
-                    // TODO: In rare cases, two matches can be found.
-                    values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON;
-                    values[1][i*3] = kmLoad.getValue();
-                    values[0][i*3+1] = station.getRange().getB().doubleValue() - EPSILON;
+            for (int k = 0; k < stations.size(); k++) {
+                MeasurementStation station = stations.get(k);
+                if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON) {
+                    // Value has been taken at measurement station.
+                    values[0][i*3]   = station.getRange().getA().doubleValue() + EPSILON;
+                    values[1][i*3]   = kmLoad.getValue();
+                    double endValue = 0d;
+                    // Valid until next measurements stations begin of range,
+                    // or end of current range if last value.
+                    if (k+2 <= stations.size()) {
+                        endValue = stations.get(k+1).getRange().getA().doubleValue();
+                    }
+                    else {
+                        endValue = station.getRange().getB().doubleValue();
+                    }
+                    values[0][i*3+1] = endValue;
                     values[1][i*3+1] = kmLoad.getValue();
-                    values[0][i*3+2] = station.getRange().getB().doubleValue();
+                    values[0][i*3+2] = endValue;
                     values[1][i*3+2] = kmLoad.getValue();
                     matchFound = true;
                 }

http://dive4elements.wald.intevation.org