changeset 5745:ed9d7e360658

Merged.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 15:00:38 +0200
parents 5bb179d4fd5f (diff) 6e6753b9757f (current diff)
children 1dab240f9f55
files
diffstat 3 files changed, 26 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadCalculation.java	Wed Apr 17 10:11:20 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadCalculation.java	Wed Apr 17 15:00:38 2013 +0200
@@ -258,23 +258,23 @@
         logger.debug("calculateTotalLoad");
         boolean problemThisYear = false;
         if (!load.hasCoarse()) {
-            addProblem("missing.fraction.coarse", Double.toString(year));
+            addProblem("missing.fraction.coarse", Integer.toString(year));
             problemThisYear = true;
         }
         if (!load.hasFineMiddle()) {
-            addProblem("missing.fraction.fine_middle", Double.toString(year));
+            addProblem("missing.fraction.fine_middle", Integer.toString(year));
             problemThisYear = true;
         }
         if (!load.hasSand()) {
-            addProblem("missing.fraction.sand", Double.toString(year));
+            addProblem("missing.fraction.sand", Integer.toString(year));
             problemThisYear = true;
         }
         if (!load.hasSuspSand()) {
-            addProblem("missing.fraction.susp_sand", Double.toString(year));
+            addProblem("missing.fraction.susp_sand", Integer.toString(year));
             problemThisYear = true;
         }
         if (!load.hasSuspSediment()) {
-            addProblem("missing.fraction.susp_sediment", Double.toString(year));
+            addProblem("missing.fraction.susp_sediment", Integer.toString(year));
             problemThisYear = true;
         }
         if (problemThisYear) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java	Wed Apr 17 10:11:20 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java	Wed Apr 17 15:00:38 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]) {
--- a/flys-backend/src/main/java/de/intevation/flys/model/Range.java	Wed Apr 17 10:11:20 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Range.java	Wed Apr 17 15:00:38 2013 +0200
@@ -19,6 +19,7 @@
 public class Range
 implements   Serializable
 {
+    public static final double EPSILON = 1e-5;
     private Integer    id;
     private BigDecimal a;
     private BigDecimal b;
@@ -73,6 +74,22 @@
         this.b = b;
     }
 
+    public boolean containsTolerant(double x) {
+            return containsTolerant(x, EPSILON);
+    }
+
+    public boolean containsTolerant(double x, double tolerance) {
+        BigDecimal b = this.b != null ? this.b : a;
+        double av = a.doubleValue();
+        double bv = b.doubleValue();
+        if (av > bv) {
+            double t = av;
+            av = bv;
+            bv = t;
+        }
+        return x+tolerance >= av && x-tolerance <= bv;
+    }
+
     public boolean contains(double x) {
         BigDecimal b = this.b != null ? this.b : a;
         double av = a.doubleValue();

http://dive4elements.wald.intevation.org