changeset 6342:b8cd8e2d0c35

SedimentLoadFacet, issue1235: Ignore values not measured at measurement stations begin of range.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 14 Jun 2013 17:09:25 +0200
parents 3ec08ff0f497
children 588e99129883
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java	Fri Jun 14 17:08:31 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java	Fri Jun 14 17:09:25 2013 +0200
@@ -99,16 +99,21 @@
         double[] km   = sd[0];
         double[] load = sd[1];
 
+        // Build map of km->load, but directly exclude the ones which do
+        // not match against a measurements station ranges start.
         for (int i = 0 ; i < km.length; i++) {
-            sortedKmLoad.put(km[i], load[i]);
+            for (MeasurementStation station: stations) {
+                if (Math.abs(station.getStation() - km[i]) <= EPSILON) {
+                    sortedKmLoad.put(km[i], load[i]);
+                    continue;
+                }
+            }
         }
 
         // [0] -> x, [1] -> y
         double[][] values = new double[2][];
-        values[0] = new double[km.length*3];
-        values[1] = new double[km.length*3];
-
-        List<double[]> kmWithoutStation = new ArrayList<double[]>();
+        values[0] = new double[sortedKmLoad.size()*3];
+        values[1] = new double[sortedKmLoad.size()*3];
 
         // Find station via its station (km).
         // TODO use a binarySearch instead of linear absdiff approach

http://dive4elements.wald.intevation.org