comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java @ 7375:450582bcad75

Replaced tabs with 4 spaces.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 17 Oct 2013 15:13:32 +0200
parents 82191d111130
children 2a2e89c01588
comparison
equal deleted inserted replaced
7374:82191d111130 7375:450582bcad75
118 118
119 public void parse(File file) throws IOException, ParseException { 119 public void parse(File file) throws IOException, ParseException {
120 120
121 log.info("Parsing WST file '" + file + "'"); 121 log.info("Parsing WST file '" + file + "'");
122 122
123 if (wst == null) { 123 if (wst == null) {
124 wst = new ImportWst(file.getName()); 124 wst = new ImportWst(file.getName());
125 } 125 }
126 else { 126 else {
127 wst.setDescription(file.getName()); 127 wst.setDescription(file.getName());
128 } 128 }
129 129
130 LineNumberReader in = 130 LineNumberReader in =
131 new LineNumberReader( 131 new LineNumberReader(
132 new InputStreamReader( 132 new InputStreamReader(
133 new FileInputStream(file), ENCODING)); 133 new FileInputStream(file), ENCODING));
346 if (kmHist2 != null && 346 if (kmHist2 != null &&
347 kmHist2.compareTo(kmHist1) != kmHist1.compareTo(kaem)) { 347 kmHist2.compareTo(kmHist1) != kmHist1.compareTo(kaem)) {
348 throw new ParseException("Stations in " + file + 348 throw new ParseException("Stations in " + file +
349 " near line " + in.getLineNumber() + 349 " near line " + in.getLineNumber() +
350 " not ordered. File rejected."); 350 " not ordered. File rejected.");
351 } 351 }
352 352
353 // remember stations in two previous lines 353 // remember stations in two previous lines
354 kmHist2 = kmHist1; 354 kmHist2 = kmHist1;
355 kmHist1 = kaem; 355 kmHist1 = kaem;
356 356
407 407
408 // add Q-ranges obtained from previous lines 408 // add Q-ranges obtained from previous lines
409 // in case there was no further Q-line 409 // in case there was no further Q-line
410 // but only if there were values following the last Q-line 410 // but only if there were values following the last Q-line
411 if (minKm != MAX_RANGE && maxKm != MIN_RANGE) { 411 if (minKm != MAX_RANGE && maxKm != MIN_RANGE) {
412 if (kmHist1 != null && kmHist2 != null 412 if (kmHist1 != null && kmHist2 != null
413 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file 413 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file
414 BigDecimal t = minKm; minKm = maxKm; maxKm = t; 414 BigDecimal t = minKm; minKm = maxKm; maxKm = t;
415 } 415 }
416 addInterval(minKm, maxKm, aktAbfluesse); 416 addInterval(minKm, maxKm, aktAbfluesse);
417 } 417 }
418 } 418 }
419 finally { 419 finally {
420 in.close(); 420 in.close();
421 } 421 }
422 } 422 }
450 450
451 if (values == null || from == MAX_RANGE || from == MIN_RANGE) { 451 if (values == null || from == MAX_RANGE || from == MIN_RANGE) {
452 return; 452 return;
453 } 453 }
454 454
455 // expand single-line i.e. 0-lenght Q-range to minimal length 455 // expand single-line i.e. 0-lenght Q-range to minimal length
456 if (from == to) { 456 if (from == to) {
457 if (lastRange != null && lastA > lastB) { 457 if (lastRange != null && lastA > lastB) {
458 to = new BigDecimal(from.doubleValue() - INTERVAL_GAP); 458 to = new BigDecimal(from.doubleValue() - INTERVAL_GAP);
459 } 459 }
460 else { 460 else {
461 to = new BigDecimal(from.doubleValue() + INTERVAL_GAP); 461 to = new BigDecimal(from.doubleValue() + INTERVAL_GAP);
462 } 462 }
463 } 463 }
464 464
465 ImportRange range = new ImportRange(from, to); 465 ImportRange range = new ImportRange(from, to);
466 466
467 // little workaround to make the q ranges tightly fit. 467 // little workaround to make the q ranges tightly fit.
468 // Leave a very small gap to ensure that the range queries 468 // Leave a very small gap to ensure that the range queries

http://dive4elements.wald.intevation.org