Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java @ 5543:732a8bd44650
Wst Parser: Yet another attempt to fix the order of the Q ranges (made by S. Teichmann)
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Wed, 03 Apr 2013 21:02:17 +0200 |
parents | f3b270e5462e |
children | 12f4d088f088 |
comparison
equal
deleted
inserted
replaced
5542:f3b270e5462e | 5543:732a8bd44650 |
---|---|
112 | 112 |
113 String einheit = "Wasserstand [NN + m]"; | 113 String einheit = "Wasserstand [NN + m]"; |
114 | 114 |
115 HashSet<BigDecimal> kms = new HashSet<BigDecimal>(); | 115 HashSet<BigDecimal> kms = new HashSet<BigDecimal>(); |
116 | 116 |
117 BigDecimal kmHist1 = null, kmHist2 = null; | |
118 | |
117 while ((input = in.readLine()) != null) { | 119 while ((input = in.readLine()) != null) { |
118 String line = input; | 120 String line = input; |
119 if (first) { // fetch number of columns | 121 if (first) { // fetch number of columns |
120 if ((line = line.trim()).length() == 0) { | 122 if ((line = line.trim()).length() == 0) { |
121 continue; | 123 continue; |
143 if (line.startsWith("*\u001f")) { | 145 if (line.startsWith("*\u001f")) { |
144 BigDecimal [] data = | 146 BigDecimal [] data = |
145 parseLineAsDouble(line, columnCount, false, true); | 147 parseLineAsDouble(line, columnCount, false, true); |
146 | 148 |
147 if (aktAbfluesse != null) { | 149 if (aktAbfluesse != null) { |
150 if (kmHist1 != null && kmHist2 != null) { | |
151 if (kmHist1.compareTo(kmHist2) < 0) { | |
152 log.debug("swapped"); | |
153 BigDecimal t = minKm; minKm = maxKm; maxKm = t; | |
154 } | |
155 } | |
148 addInterval(minKm, maxKm, aktAbfluesse); | 156 addInterval(minKm, maxKm, aktAbfluesse); |
149 minKm = MAX_RANGE; | 157 minKm = MAX_RANGE; |
150 maxKm = MIN_RANGE; | 158 maxKm = MIN_RANGE; |
151 } | 159 } |
152 | 160 |
270 " (line " + in.getLineNumber() + | 278 " (line " + in.getLineNumber() + |
271 ") found more than once. -> ignored"); | 279 ") found more than once. -> ignored"); |
272 continue; | 280 continue; |
273 } | 281 } |
274 | 282 |
283 kmHist2 = kmHist1; | |
284 kmHist1 = kaem; | |
285 | |
275 if (kaem.compareTo(minKm) < 0) { | 286 if (kaem.compareTo(minKm) < 0) { |
276 minKm = kaem; | 287 minKm = kaem; |
277 } | 288 } |
278 if (kaem.compareTo(maxKm) > 0) { | 289 if (kaem.compareTo(maxKm) > 0) { |
279 maxKm = kaem; | 290 maxKm = kaem; |
317 } | 328 } |
318 | 329 |
319 } // for all lines in WST file | 330 } // for all lines in WST file |
320 | 331 |
321 wst.setUnit(new ImportUnit(einheit)); | 332 wst.setUnit(new ImportUnit(einheit)); |
322 | 333 if (kmHist1.compareTo(kmHist2) < 0) { |
334 BigDecimal t = minKm; minKm = maxKm; maxKm = t; | |
335 } | |
323 addInterval(minKm, maxKm, aktAbfluesse); | 336 addInterval(minKm, maxKm, aktAbfluesse); |
324 | 337 |
325 fixRangesOrder(); | 338 fixRangesOrder(); |
326 } | 339 } |
327 finally { | 340 finally { |