changeset 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 d08f77e7f7e8
children acf3b49ec31f
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java
diffstat 2 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed May 25 15:31:25 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu May 26 09:41:57 2011 +0000
@@ -1,3 +1,8 @@
+2011-05-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
+	  Round exploded values to a precision of 1e-6.
+
 2011-05-25	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	Qs are now stored in ranges for each column.
--- 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