[Dive4elements-commits] [PATCH 3 of 4] SedimentLoadFacet, issue1235: Ignore values not measured at measurement stations

Wald Commits scm-commit at wald.intevation.org
Fri Jun 14 17:02:51 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1371222565 -7200
# Node ID b8cd8e2d0c3553411512c10783ebe43e4bfb1161
# Parent  3ec08ff0f4974fcc85f352ebd6eb5e9ea14df9af
SedimentLoadFacet, issue1235: Ignore values not measured at measurement stations
begin of range.

diff -r 3ec08ff0f497 -r b8cd8e2d0c35 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java
--- 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


More information about the Dive4elements-commits mailing list