changeset 5744:5bb179d4fd5f

SedimentLoadFacet: Avoid weird steps, find correct measurement stations.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 14:53:16 +0200
parents 80b9218ac007
children ed9d7e360658
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java
diffstat 1 files changed, 4 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java	Wed Apr 17 14:52:19 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java	Wed Apr 17 14:53:16 2013 +0200
@@ -105,7 +105,9 @@
             boolean matchFound = false;
             // For now, ignore overlaps like (B> next A)
             for (MeasurementStation station: stations) {
-                if (Math.abs(station.getStation() - entry.getKey()) < EPSILON) {
+                if (Math.abs(station.getStation() - entry.getKey()) < EPSILON ||
+                    station.getRange().containsTolerant(entry.getKey())) {
+                    // TODO: In rare cases, two matches can be found.
                     values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON;
                     values[1][i*3] = entry.getValue();
                     values[0][i*3+1] = station.getRange().getB().doubleValue() - EPSILON;
@@ -117,30 +119,12 @@
             }
             // Store points without match for later assessment.
             if (!matchFound) {
-                kmWithoutStation.add(new double[] {entry.getKey(), entry.getValue(), i});
+                logger.warn("measurement without station ("+entry.getKey()+")!");
             }
             i++;
         }
 
-        // Find fitting measurement stations for values without match.
-        for (double misses[]: kmWithoutStation) {
-             int idc = Math.abs(Collections.binarySearch(sortedStarts, misses[0]));
-             double locationA = sortedStarts.get(idc-2);
-             double locationB = sortedStarts.get(idc-1);
-             values[0][(int)misses[2]*3] = locationA + EPSILON;
-             values[1][(int)misses[2]*3] = misses[1];
-             values[0][(int)misses[2]*3+1] = locationB - EPSILON;
-             values[1][(int)misses[2]*3+1] = misses[1];
-             values[0][(int)misses[2]*3+2] = locationB ;
-             values[1][(int)misses[2]*3+2] = misses[1];
-        }
-
-
         for (int x = 0; x < values[0].length-1; x++) {
-            // Correct measurement stationo overlap.
-            if (values[0][x] > values[0][x+1]) {
-                values[0][x+1] = values[0][x] + EPSILON;
-            }
             // Introduce gaps where no data in measurement station.
             if (Math.abs(values[0][x+1] - values[0][x]) > 3*EPSILON
                     && values[1][x+1] != values[1][x]) {

http://dive4elements.wald.intevation.org