diff flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java @ 5379:61bf64b102bc mapgenfix

Merge with default branch
author Christian Lins <christian.lins@intevation.de>
date Fri, 22 Mar 2013 11:25:54 +0100
parents 240ff7aeb6de
children
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Wed Mar 06 14:14:15 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Fri Mar 22 11:25:54 2013 +0100
@@ -16,6 +16,9 @@
 
     public static final double DEFAULT_STEP_PRECISION = 1e6;
 
+    /** EPSILON for comparison of double precision values. */
+    public static final double EPSILON = 1e-4;
+
     private DoubleUtil() {
     }
 
@@ -31,6 +34,10 @@
         return Math.round(x * DEFAULT_STEP_PRECISION)/DEFAULT_STEP_PRECISION;
     }
 
+    /**
+     * Returns array with values from parameter from to to with given step width.
+     * from and to are included.
+     */
     public static final double [] explode(
         double from,
         double to,
@@ -56,7 +63,7 @@
         double max = Math.max(from, to);
 
         for (int idx = 0; idx < num; idx++) {
-            if (lower > max) {
+            if (lower - max > EPSILON) {
                 return Arrays.copyOfRange(values, 0, idx);
             }
 
@@ -177,7 +184,7 @@
 
                 vs.resetQuick();
 
-                for (String valueStr: parts[2].split(",")) {
+                for (String valueStr: parts[3].split(",")) {
                     vs.add(round(Double.parseDouble(valueStr.trim())));
                 }
 

http://dive4elements.wald.intevation.org