changeset 7605:f51c943c707a

(issue1560) Fix off by one error in ATWriter causing the last value to be omitted.
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 27 Nov 2013 17:17:54 +0100
parents 05549a84ee83
children 424c3d84e119
files artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java	Wed Nov 27 16:21:00 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java	Wed Nov 27 17:17:54 2013 +0100
@@ -170,10 +170,13 @@
             return;
         }
 
-        double [] ws = new double[bounds[1]-bounds[0]];
+        /* example: bounds[0] = 0
+         * bounds[1] = 5 -> we need to store 6 values.*/
+
+        double [] ws = new double[bounds[1]-bounds[0] + 1];
         double [] qs = new double[ws.length];
 
-        for (int i = 0; i < ws.length; ++i) {
+        for (int i = 0; i < ws.length; i++) {
             int idx = bounds[0]+i;
             ws[i] = wq.getW(idx);
             qs[i] = wq.getQ(idx);
@@ -213,7 +216,7 @@
         }
 
         int col = 0;
-        for (int w = startW; w < maxW; w++) {
+        for (int w = startW; w <= maxW; w++) {
             if (col == 0) {
                 out.printf(Locale.US, "%8d", w);
             }

http://dive4elements.wald.intevation.org