changeset 753:677a6fceea6e

flys/issue76: Close gaps between q ranges flys-backend/trunk@1981 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 23 May 2011 15:01:58 +0000
parents 06e8d0b8fad9
children 5bcf338eadb9
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/WstParser.java
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri May 20 09:30:08 2011 +0000
+++ b/flys-backend/ChangeLog	Mon May 23 15:01:58 2011 +0000
@@ -1,3 +1,10 @@
+2011-05-23	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	 flys/issue76
+
+	* src/main/java/de/intevation/flys/importer/WstParser.java:
+	  Close gaps between q ranges.
+
 2011-05-20  Ingo Weinzierl <ingo@intevation.de>
 
 	Tagged RELEASE 2.3.1
--- a/flys-backend/src/main/java/de/intevation/flys/importer/WstParser.java	Fri May 20 09:30:08 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/WstParser.java	Mon May 23 15:01:58 2011 +0000
@@ -44,8 +44,13 @@
     public static final Pattern UNIT =
         Pattern.compile("[^\\[]*\\[([^]]+)\\].*");
 
+    public static final BigDecimal INTERVAL_GAP =
+        new BigDecimal(0.00001);
+
     protected ImportWst wst;
 
+    protected ImportRange lastRange;
+
     public WstParser() {
     }
 
@@ -339,11 +344,31 @@
 
         ImportRange range = new ImportRange(from, to);
 
+        // little workaround to make the q ranges tightly fit.
+        // Leave a very small gap to ensure that the range queries
+        // still work.
+
+        if (lastRange != null) {
+            double d1 = Math.abs(
+                lastRange.getB().doubleValue() - range.getA().doubleValue());
+            double d2 = Math.abs(
+                range.getB().doubleValue() - lastRange.getA().doubleValue());
+
+            if (d1 < d2) {
+                lastRange.setB(range.getA().subtract(INTERVAL_GAP));
+            }
+            else {
+                range.setA(lastRange.getB().subtract(INTERVAL_GAP));
+            }
+        }
+
         for (int i = 0; i < values.length; ++i) {
             ImportWstColumn column = wst.getColumn(i);
             ImportWstQRange wstQRange = new ImportWstQRange(range, values[i]);
             column.addColumnQRange(wstQRange);
         }
+
+        lastRange = range;
     }
 
     private static final BigDecimal [] parseLineAsDouble(

http://dive4elements.wald.intevation.org