Mercurial > dive4elements > river
changeset 7374:82191d111130
WstParser: Do not add Q-range for trailing Q-line.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 17 Oct 2013 15:05:08 +0200 |
parents | 793dfb2f4b7b |
children | 450582bcad75 |
files | backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java |
diffstat | 1 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Thu Oct 17 12:14:10 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Thu Oct 17 15:05:08 2013 +0200 @@ -186,11 +186,12 @@ line = line.replace(',', '.'); + // handle Q-lines if (line.startsWith("*\u001f")) { BigDecimal [] data = parseLineAsDouble(line, columnCount, false, true); - if (aktAbfluesse != null) { + if (aktAbfluesse != null) { // add Q-ranges obtained from previous lines if (kmHist1 != null && kmHist2 != null && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file BigDecimal t = minKm; minKm = maxKm; maxKm = t; @@ -200,6 +201,7 @@ maxKm = MIN_RANGE; } + // obtain Q-values from current line aktAbfluesse = new BigDecimal[columnCount]; log.debug("new q range: " + columnCount); for (int i = 0; i < Math.min(columnCount, data.length); ++i) { @@ -215,6 +217,7 @@ continue; } + // handle special column identifiers if (line.startsWith("*!")) { String spezial = line.substring(2).trim(); @@ -265,6 +268,7 @@ continue; } + // handle comment lines to fetch unit if (line.startsWith("*")) { Matcher m = UNIT_COMMENT.matcher(line); if (m.matches()) { @@ -401,11 +405,16 @@ } wst.setUnit(new ImportUnit(einheit)); - if (kmHist1 != null && kmHist2 != null - && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file - BigDecimal t = minKm; minKm = maxKm; maxKm = t; - } - addInterval(minKm, maxKm, aktAbfluesse); + // add Q-ranges obtained from previous lines + // in case there was no further Q-line + // but only if there were values following the last Q-line + if (minKm != MAX_RANGE && maxKm != MIN_RANGE) { + if (kmHist1 != null && kmHist2 != null + && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file + BigDecimal t = minKm; minKm = maxKm; maxKm = t; + } + addInterval(minKm, maxKm, aktAbfluesse); + } } finally { in.close();