diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 634:d8c47520c726

Round exploded values to a precision of 1e-6. flys-artifacts/trunk@2008 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 May 2011 09:41:57 +0000
parents a9af60c84dca
children acf3b49ec31f
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Wed May 25 15:31:25 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu May 26 09:41:57 2011 +0000
@@ -74,6 +74,8 @@
     /** The default step width between the start end end kilometer.*/
     public static final double DEFAULT_KM_STEPS = 0.1;
 
+    public static final double DEFAULT_PRECISION = 1e6;
+
 
     /** The identifier of the current state. */
     protected String currentStateId;
@@ -906,7 +908,20 @@
      *
      * @return an array of double values.
      */
-    public static double[] getExplodedValues(double from, double to, double step) {
+    public static double[] getExplodedValues(
+        double from, 
+        double to, 
+        double step
+    ) {
+        return getExplodedValues(from, to, step, DEFAULT_PRECISION);
+    }
+
+    public static double[] getExplodedValues(
+        double from, 
+        double to, 
+        double step,
+        double precision
+    ) {
         double lower = from;
 
         double diff = to - from;
@@ -916,7 +931,7 @@
         double [] values = new double[num];
 
         for (int idx = 0; idx < num; idx++) {
-            values[idx] = lower;
+            values[idx] = Math.round(lower * precision)/precision;
             lower      += step;
         }
 

http://dive4elements.wald.intevation.org