Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/WstParser.java @ 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 | a92da0b3e8e7 |
children | 6dc847194625 |
line wrap: on
line diff
--- 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(