comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java @ 5541:b09c095a0b7e

WST Importer: Potential fix for tighten gaps between Q ranges.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 03 Apr 2013 17:59:11 +0200
parents 0d27d02b1208
children f3b270e5462e
comparison
equal deleted inserted replaced
5540:25c2505df28f 5541:b09c095a0b7e
50 Pattern.compile("\\*\\s*[kK][mM]\\s+(.+)"); 50 Pattern.compile("\\*\\s*[kK][mM]\\s+(.+)");
51 51
52 public static final Pattern UNIT = 52 public static final Pattern UNIT =
53 Pattern.compile("[^\\[]*\\[([^]]+)\\].*"); 53 Pattern.compile("[^\\[]*\\[([^]]+)\\].*");
54 54
55 public static final BigDecimal INTERVAL_GAP = 55 public static final double INTERVAL_GAP = 0.00001d;
56 new BigDecimal(0.00001);
57 56
58 protected ImportWst wst; 57 protected ImportWst wst;
59 58
60 protected ImportRange lastRange; 59 protected ImportRange lastRange;
61 60
370 // little workaround to make the q ranges tightly fit. 369 // little workaround to make the q ranges tightly fit.
371 // Leave a very small gap to ensure that the range queries 370 // Leave a very small gap to ensure that the range queries
372 // still work. 371 // still work.
373 372
374 if (lastRange != null) { 373 if (lastRange != null) {
375 double d1 = Math.abs( 374 double a1 = lastRange.getA().doubleValue();
376 lastRange.getB().doubleValue() - range.getA().doubleValue()); 375 double b1 = lastRange.getB().doubleValue();
377 double d2 = Math.abs( 376 double a2 = range.getA().doubleValue();
378 range.getB().doubleValue() - lastRange.getA().doubleValue()); 377
379 378 if (a1 < b1) {
380 if (d1 < d2) { 379 lastRange.setB(new BigDecimal(a2 - INTERVAL_GAP));
381 lastRange.setB(range.getA().subtract(INTERVAL_GAP)); 380 }
382 } 381 else { // a1 >= b1
383 else { 382 lastRange.setB(new BigDecimal(a2 + INTERVAL_GAP));
384 range.setA(lastRange.getB().subtract(INTERVAL_GAP));
385 } 383 }
386 } 384 }
387 385
388 for (int i = 0; i < values.length; ++i) { 386 for (int i = 0; i < values.length; ++i) {
389 ImportWstColumn column = wst.getColumn(i); 387 ImportWstColumn column = wst.getColumn(i);

http://dive4elements.wald.intevation.org