Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java @ 8664:b9e5fa7f7a28
(issue1787) Do not accept any non-NaN W-value but check for epsilon.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Tue, 07 Apr 2015 16:35:11 +0200 |
parents | b78ca00d4659 |
children | 93a31cfb18c0 |
comparison
equal
deleted
inserted
replaced
8663:b78ca00d4659 | 8664:b9e5fa7f7a28 |
---|---|
42 private static Logger log = Logger.getLogger(WstValueTable.class); | 42 private static Logger log = Logger.getLogger(WstValueTable.class); |
43 | 43 |
44 public static final int DEFAULT_Q_STEPS = 500; | 44 public static final int DEFAULT_Q_STEPS = 500; |
45 | 45 |
46 public static final int RELATE_WS_SAMPLES = 200; | 46 public static final int RELATE_WS_SAMPLES = 200; |
47 | |
48 public static final double W_EPSILON = 0.000001; | |
47 | 49 |
48 /** | 50 /** |
49 * A Column in the table, typically representing one measurement session. | 51 * A Column in the table, typically representing one measurement session. |
50 */ | 52 */ |
51 public static final class Column | 53 public static final class Column |
414 | 416 |
415 public double [] findQsForW(double w, WstValueTable table) { | 417 public double [] findQsForW(double w, WstValueTable table) { |
416 | 418 |
417 TDoubleArrayList qs = new TDoubleArrayList(); | 419 TDoubleArrayList qs = new TDoubleArrayList(); |
418 | 420 |
419 if (ws.length > 0 && Math.abs(ws[0]-w) < 0.000001) { | 421 if (ws.length > 0 && Math.abs(ws[0]-w) < W_EPSILON) { |
420 double q = table.getQIndex(0, km); | 422 double q = table.getQIndex(0, km); |
421 if (!Double.isNaN(q)) { | 423 if (!Double.isNaN(q)) { |
422 qs.add(q); | 424 qs.add(q); |
423 } | 425 } |
424 } | 426 } |
426 for (int i = 1; i < ws.length; ++i) { | 428 for (int i = 1; i < ws.length; ++i) { |
427 double w2 = ws[i]; | 429 double w2 = ws[i]; |
428 if (Double.isNaN(w2)) { | 430 if (Double.isNaN(w2)) { |
429 continue; | 431 continue; |
430 } | 432 } |
431 if (Math.abs(w2-w) < 0.000001) { | 433 if (Math.abs(w2-w) < W_EPSILON) { |
432 double q = table.getQIndex(i, km); | 434 double q = table.getQIndex(i, km); |
433 if (!Double.isNaN(q)) { | 435 if (!Double.isNaN(q)) { |
434 qs.add(q); | 436 qs.add(q); |
435 } | 437 } |
436 continue; | 438 continue; |
467 | 469 |
468 double factor = Linear.factor(km, this.km, other.km); | 470 double factor = Linear.factor(km, this.km, other.km); |
469 | 471 |
470 if (ws.length > 0) { | 472 if (ws.length > 0) { |
471 double wt = Linear.weight(factor, ws[0], other.ws[0]); | 473 double wt = Linear.weight(factor, ws[0], other.ws[0]); |
472 if (!Double.isNaN(wt)) { | 474 if (Math.abs(wt-w) < W_EPSILON) { |
473 double q = table.getQIndex(0, km); | 475 double q = table.getQIndex(0, km); |
474 if (!Double.isNaN(q)) { | 476 if (!Double.isNaN(q)) { |
475 qs.add(q); | 477 qs.add(q); |
476 } | 478 } |
477 } | 479 } |
480 for (int i = 1; i < ws.length; ++i) { | 482 for (int i = 1; i < ws.length; ++i) { |
481 double w2 = Linear.weight(factor, ws[i], other.ws[i]); | 483 double w2 = Linear.weight(factor, ws[i], other.ws[i]); |
482 if (Double.isNaN(w2)) { | 484 if (Double.isNaN(w2)) { |
483 continue; | 485 continue; |
484 } | 486 } |
485 if (Math.abs(w2-w) < 0.000001) { | 487 if (Math.abs(w2-w) < W_EPSILON) { |
486 double q = table.getQIndex(i, km); | 488 double q = table.getQIndex(i, km); |
487 if (!Double.isNaN(q)) { | 489 if (!Double.isNaN(q)) { |
488 qs.add(q); | 490 qs.add(q); |
489 } | 491 } |
490 continue; | 492 continue; |
491 } | 493 } |
494 | |
492 double w1 = Linear.weight(factor, ws[i-1], other.ws[i-1]); | 495 double w1 = Linear.weight(factor, ws[i-1], other.ws[i-1]); |
493 if (Double.isNaN(w1)) { | 496 if (Double.isNaN(w1)) { |
494 continue; | 497 continue; |
495 } | 498 } |
496 | 499 |