Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java @ 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 | c9b9176b0530 |
children | 450582bcad75 |
comparison
equal
deleted
inserted
replaced
7373:793dfb2f4b7b | 7374:82191d111130 |
---|---|
184 continue; | 184 continue; |
185 } | 185 } |
186 | 186 |
187 line = line.replace(',', '.'); | 187 line = line.replace(',', '.'); |
188 | 188 |
189 // handle Q-lines | |
189 if (line.startsWith("*\u001f")) { | 190 if (line.startsWith("*\u001f")) { |
190 BigDecimal [] data = | 191 BigDecimal [] data = |
191 parseLineAsDouble(line, columnCount, false, true); | 192 parseLineAsDouble(line, columnCount, false, true); |
192 | 193 |
193 if (aktAbfluesse != null) { | 194 if (aktAbfluesse != null) { // add Q-ranges obtained from previous lines |
194 if (kmHist1 != null && kmHist2 != null | 195 if (kmHist1 != null && kmHist2 != null |
195 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file | 196 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file |
196 BigDecimal t = minKm; minKm = maxKm; maxKm = t; | 197 BigDecimal t = minKm; minKm = maxKm; maxKm = t; |
197 } | 198 } |
198 addInterval(minKm, maxKm, aktAbfluesse); | 199 addInterval(minKm, maxKm, aktAbfluesse); |
199 minKm = MAX_RANGE; | 200 minKm = MAX_RANGE; |
200 maxKm = MIN_RANGE; | 201 maxKm = MIN_RANGE; |
201 } | 202 } |
202 | 203 |
204 // obtain Q-values from current line | |
203 aktAbfluesse = new BigDecimal[columnCount]; | 205 aktAbfluesse = new BigDecimal[columnCount]; |
204 log.debug("new q range: " + columnCount); | 206 log.debug("new q range: " + columnCount); |
205 for (int i = 0; i < Math.min(columnCount, data.length); ++i) { | 207 for (int i = 0; i < Math.min(columnCount, data.length); ++i) { |
206 if (data[i] != null) { | 208 if (data[i] != null) { |
207 log.debug(" column: " + data[i]); | 209 log.debug(" column: " + data[i]); |
213 firstAbfluesse = (BigDecimal [])aktAbfluesse.clone(); | 215 firstAbfluesse = (BigDecimal [])aktAbfluesse.clone(); |
214 } | 216 } |
215 continue; | 217 continue; |
216 } | 218 } |
217 | 219 |
220 // handle special column identifiers | |
218 if (line.startsWith("*!")) { | 221 if (line.startsWith("*!")) { |
219 String spezial = line.substring(2).trim(); | 222 String spezial = line.substring(2).trim(); |
220 | 223 |
221 if (spezial.length() == 0) { | 224 if (spezial.length() == 0) { |
222 continue; | 225 continue; |
263 | 266 |
264 if (line.length() < 11) { | 267 if (line.length() < 11) { |
265 continue; | 268 continue; |
266 } | 269 } |
267 | 270 |
271 // handle comment lines to fetch unit | |
268 if (line.startsWith("*")) { | 272 if (line.startsWith("*")) { |
269 Matcher m = UNIT_COMMENT.matcher(line); | 273 Matcher m = UNIT_COMMENT.matcher(line); |
270 if (m.matches()) { | 274 if (m.matches()) { |
271 log.debug("unit comment found"); | 275 log.debug("unit comment found"); |
272 // XXX: This hack is needed because desktop | 276 // XXX: This hack is needed because desktop |
399 if (!unitFound) { | 403 if (!unitFound) { |
400 log.warn("no unit and height reference found. Using default."); | 404 log.warn("no unit and height reference found. Using default."); |
401 } | 405 } |
402 wst.setUnit(new ImportUnit(einheit)); | 406 wst.setUnit(new ImportUnit(einheit)); |
403 | 407 |
404 if (kmHist1 != null && kmHist2 != null | 408 // add Q-ranges obtained from previous lines |
405 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file | 409 // in case there was no further Q-line |
406 BigDecimal t = minKm; minKm = maxKm; maxKm = t; | 410 // but only if there were values following the last Q-line |
407 } | 411 if (minKm != MAX_RANGE && maxKm != MIN_RANGE) { |
408 addInterval(minKm, maxKm, aktAbfluesse); | 412 if (kmHist1 != null && kmHist2 != null |
413 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file | |
414 BigDecimal t = minKm; minKm = maxKm; maxKm = t; | |
415 } | |
416 addInterval(minKm, maxKm, aktAbfluesse); | |
417 } | |
409 } | 418 } |
410 finally { | 419 finally { |
411 in.close(); | 420 in.close(); |
412 } | 421 } |
413 } | 422 } |