Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
752:06e8d0b8fad9 | 753:677a6fceea6e |
---|---|
42 Pattern.compile("\\*\\s*[kK][mM]\\s+(.+)"); | 42 Pattern.compile("\\*\\s*[kK][mM]\\s+(.+)"); |
43 | 43 |
44 public static final Pattern UNIT = | 44 public static final Pattern UNIT = |
45 Pattern.compile("[^\\[]*\\[([^]]+)\\].*"); | 45 Pattern.compile("[^\\[]*\\[([^]]+)\\].*"); |
46 | 46 |
47 public static final BigDecimal INTERVAL_GAP = | |
48 new BigDecimal(0.00001); | |
49 | |
47 protected ImportWst wst; | 50 protected ImportWst wst; |
51 | |
52 protected ImportRange lastRange; | |
48 | 53 |
49 public WstParser() { | 54 public WstParser() { |
50 } | 55 } |
51 | 56 |
52 public ImportWst getWst() { | 57 public ImportWst getWst() { |
337 BigDecimal t = from; from = to; to = t; | 342 BigDecimal t = from; from = to; to = t; |
338 } | 343 } |
339 | 344 |
340 ImportRange range = new ImportRange(from, to); | 345 ImportRange range = new ImportRange(from, to); |
341 | 346 |
347 // little workaround to make the q ranges tightly fit. | |
348 // Leave a very small gap to ensure that the range queries | |
349 // still work. | |
350 | |
351 if (lastRange != null) { | |
352 double d1 = Math.abs( | |
353 lastRange.getB().doubleValue() - range.getA().doubleValue()); | |
354 double d2 = Math.abs( | |
355 range.getB().doubleValue() - lastRange.getA().doubleValue()); | |
356 | |
357 if (d1 < d2) { | |
358 lastRange.setB(range.getA().subtract(INTERVAL_GAP)); | |
359 } | |
360 else { | |
361 range.setA(lastRange.getB().subtract(INTERVAL_GAP)); | |
362 } | |
363 } | |
364 | |
342 for (int i = 0; i < values.length; ++i) { | 365 for (int i = 0; i < values.length; ++i) { |
343 ImportWstColumn column = wst.getColumn(i); | 366 ImportWstColumn column = wst.getColumn(i); |
344 ImportWstQRange wstQRange = new ImportWstQRange(range, values[i]); | 367 ImportWstQRange wstQRange = new ImportWstQRange(range, values[i]); |
345 column.addColumnQRange(wstQRange); | 368 column.addColumnQRange(wstQRange); |
346 } | 369 } |
370 | |
371 lastRange = range; | |
347 } | 372 } |
348 | 373 |
349 private static final BigDecimal [] parseLineAsDouble( | 374 private static final BigDecimal [] parseLineAsDouble( |
350 String line, | 375 String line, |
351 int count, | 376 int count, |