[Dive4elements-commits] [PATCH 3 of 4] SedimentLoadFacet: Avoid weird steps, find correct measurement stations

Wald Commits scm-commit at wald.intevation.org
Wed Apr 17 14:52:46 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1366203196 -7200
# Node ID 5bb179d4fd5f74fa96e9561392786a22d4d6e97e
# Parent  80b9218ac0071d786ff312ad324b5cb83568af1f
SedimentLoadFacet: Avoid weird steps, find correct measurement stations.

diff -r 80b9218ac007 -r 5bb179d4fd5f flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java
--- 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]) {


More information about the Dive4elements-commits mailing list