Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java @ 7222:c5214e04b9b8 double-precision
WST-parser: making ranges tightly fit was broken since a<b was enforced. Re-enabled.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 01 Oct 2013 18:46:30 +0200 |
parents | 3d83a4cf33ba |
children | 2ce7bacc940f |
comparison
equal
deleted
inserted
replaced
7221:70ab9e8cdefb | 7222:c5214e04b9b8 |
---|---|
67 public static final double INTERVAL_GAP = 0.00001d; | 67 public static final double INTERVAL_GAP = 0.00001d; |
68 | 68 |
69 protected ImportWst wst; | 69 protected ImportWst wst; |
70 | 70 |
71 protected ImportRange lastRange; | 71 protected ImportRange lastRange; |
72 protected Double lastA; | |
73 protected Double lastB; | |
72 | 74 |
73 public WstParser() { | 75 public WstParser() { |
74 } | 76 } |
75 | 77 |
76 public WstParser(ImportWst wst) { | 78 public WstParser(ImportWst wst) { |
420 | 422 |
421 if (values == null || from == MAX_RANGE || from == MIN_RANGE) { | 423 if (values == null || from == MAX_RANGE || from == MIN_RANGE) { |
422 return; | 424 return; |
423 } | 425 } |
424 | 426 |
425 Double a1 = null; | |
426 Double b1 = null; | |
427 if (lastRange != null) { | |
428 a1 = lastRange.getA().doubleValue(); | |
429 b1 = lastRange.getB().doubleValue(); | |
430 } | |
431 | |
432 // expand single-line i.e. 0-lenght Q-range to minimal length | 427 // expand single-line i.e. 0-lenght Q-range to minimal length |
433 if (from == to) { | 428 if (from == to) { |
434 if (lastRange != null && a1 > b1) { | 429 if (lastRange != null && lastA > lastB) { |
435 to = new BigDecimal(from.doubleValue() - INTERVAL_GAP); | 430 to = new BigDecimal(from.doubleValue() - INTERVAL_GAP); |
436 } | 431 } |
437 else { | 432 else { |
438 to = new BigDecimal(from.doubleValue() + INTERVAL_GAP); | 433 to = new BigDecimal(from.doubleValue() + INTERVAL_GAP); |
439 } | 434 } |
445 // Leave a very small gap to ensure that the range queries | 440 // Leave a very small gap to ensure that the range queries |
446 // still work. | 441 // still work. |
447 | 442 |
448 if (lastRange != null) { | 443 if (lastRange != null) { |
449 double a2 = range.getA().doubleValue(); | 444 double a2 = range.getA().doubleValue(); |
450 | 445 double b2 = range.getB().doubleValue(); |
451 if (a1 < b1) { | 446 |
447 if (lastA < lastB) { | |
452 lastRange.setB(new BigDecimal(a2 - INTERVAL_GAP)); | 448 lastRange.setB(new BigDecimal(a2 - INTERVAL_GAP)); |
453 } | 449 } |
454 else { // a1 >= b1 | 450 else { // lastA >= lastB |
455 lastRange.setB(new BigDecimal(a2 + INTERVAL_GAP)); | 451 lastRange.setA(new BigDecimal(b2 + INTERVAL_GAP)); |
456 } | 452 } |
457 } | 453 } |
458 | 454 |
459 for (int i = 0; i < values.length; ++i) { | 455 for (int i = 0; i < values.length; ++i) { |
460 ImportWstColumn column = wst.getColumn(i); | 456 ImportWstColumn column = wst.getColumn(i); |
461 ImportWstQRange wstQRange = new ImportWstQRange(range, values[i]); | 457 ImportWstQRange wstQRange = new ImportWstQRange(range, values[i]); |
462 column.addColumnQRange(wstQRange); | 458 column.addColumnQRange(wstQRange); |
463 } | 459 } |
464 | 460 |
461 lastA = from.doubleValue(); | |
462 lastB = to.doubleValue(); | |
465 lastRange = range; | 463 lastRange = range; |
466 } | 464 } |
467 | 465 |
468 private static final BigDecimal [] parseLineAsDouble( | 466 private static final BigDecimal [] parseLineAsDouble( |
469 String line, | 467 String line, |