[PATCH] (issue1787) Do not accept any non-NaN W-value but check for epsilon

Wald Commits scm-commit at wald.intevation.org
Tue Apr 7 16:35:14 CEST 2015


# HG changeset patch
# User "Tom Gottfried <tom at intevation.de>"
# Date 1428417311 -7200
# Node ID b9e5fa7f7a280e4247b1bf719d8bd54d476a3210
# Parent  b78ca00d46597b245af0caad62c5594e3480abd9
(issue1787) Do not accept any non-NaN W-value but check for epsilon.

diff -r b78ca00d4659 -r b9e5fa7f7a28 artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java	Tue Apr 07 12:10:45 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java	Tue Apr 07 16:35:11 2015 +0200
@@ -45,6 +45,8 @@
 
     public static final int RELATE_WS_SAMPLES = 200;
 
+    public static final double W_EPSILON = 0.000001;
+
     /**
      * A Column in the table, typically representing one measurement session.
      */
@@ -416,7 +418,7 @@
 
             TDoubleArrayList qs = new TDoubleArrayList();
 
-            if (ws.length > 0 && Math.abs(ws[0]-w) < 0.000001) {
+            if (ws.length > 0 && Math.abs(ws[0]-w) < W_EPSILON) {
                 double q = table.getQIndex(0, km);
                 if (!Double.isNaN(q)) {
                     qs.add(q);
@@ -428,7 +430,7 @@
                 if (Double.isNaN(w2)) {
                     continue;
                 }
-                if (Math.abs(w2-w) < 0.000001) {
+                if (Math.abs(w2-w) < W_EPSILON) {
                     double q = table.getQIndex(i, km);
                     if (!Double.isNaN(q)) {
                         qs.add(q);
@@ -469,7 +471,7 @@
 
             if (ws.length > 0) {
                 double wt = Linear.weight(factor, ws[0], other.ws[0]);
-                if (!Double.isNaN(wt)) {
+                if (Math.abs(wt-w) < W_EPSILON) {
                     double q = table.getQIndex(0, km);
                     if (!Double.isNaN(q)) {
                         qs.add(q);
@@ -482,13 +484,14 @@
                 if (Double.isNaN(w2)) {
                     continue;
                 }
-                if (Math.abs(w2-w) < 0.000001) {
+                if (Math.abs(w2-w) < W_EPSILON) {
                     double q = table.getQIndex(i, km);
                     if (!Double.isNaN(q)) {
                         qs.add(q);
                     }
                     continue;
                 }
+
                 double w1 = Linear.weight(factor, ws[i-1], other.ws[i-1]);
                 if (Double.isNaN(w1)) {
                     continue;


More information about the Dive4Elements-commits mailing list