[PATCH] (issue1772) Use 0.001km tolarance instead of 0.1 to find matching km

Wald Commits scm-commit at wald.intevation.org
Tue Nov 18 15:24:46 CET 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1416320680 -3600
# Node ID 3f505fba522fdb731c3362561bbcea1e4406a492
# Parent  a846a3d910a0064462fc8ed98bbd34b4ec01c7c9
(issue1772) Use 0.001km tolarance instead of 0.1 to find matching km.

    There is no sense to use a define here. I will not write
    static final double NULLPOINTNULLNULLONE=0.001 if i just want to use that
    value and not any other value which may make sense in some other place.

    Using hardcoded values can have its merits and makes the code easier to
    read.

diff -r a846a3d910a0 -r 3f505fba522f artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java	Thu Nov 13 13:28:45 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java	Tue Nov 18 15:24:40 2014 +0100
@@ -452,7 +452,9 @@
 
             double[] kms = wqkms.getKms();
             for (int i = 0 ; i< kms.length; i++) {
-                if (Math.abs(kms[i] - ckm) <= GAUGE_EPSILON) {
+                /* We use a tolerance of 1m here to find a hit.
+                 * Probably to avoid some rounding errors. */
+                if (Math.abs(kms[i] - ckm) <= 0.001) {
                     series.add(wqkms.getQ(i), wqkms.getW(i), false);
                     generator.addAxisSeries(series, axisName, visible);
                     if(visible && theme.parseShowPointLabel()) {


More information about the Dive4Elements-commits mailing list