Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/PRFParser.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | f3078357ec65 |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
105 String first = line.substring( | 105 String first = line.substring( |
106 pos, pos + firstIntegerPlaces); | 106 pos, pos + firstIntegerPlaces); |
107 | 107 |
108 String second = line.substring( | 108 String second = line.substring( |
109 pos + firstIntegerPlaces, | 109 pos + firstIntegerPlaces, |
110 Math.min(L, pos + firstIntegerPlaces + secondIntegerPlaces)); | 110 Math.min( |
111 L, pos + firstIntegerPlaces + secondIntegerPlaces)); | |
111 | 112 |
112 double x, y; | 113 double x, y; |
113 try { | 114 try { |
114 x = Double.parseDouble(first); | 115 x = Double.parseDouble(first); |
115 y = Double.parseDouble(second); | 116 y = Double.parseDouble(second); |
282 } | 283 } |
283 | 284 |
284 Matcher m = DATA_PATTERN.matcher(line); | 285 Matcher m = DATA_PATTERN.matcher(line); |
285 | 286 |
286 if (!m.matches()) { | 287 if (!m.matches()) { |
287 log.warn("PRF: First line does not look like a PRF data pattern."); | 288 log.warn( |
289 "PRF: First line does not look like a PRF data pattern."); | |
288 return false; | 290 return false; |
289 } | 291 } |
290 | 292 |
291 DataFormat dataFormat = new DataFormat(m); | 293 DataFormat dataFormat = new DataFormat(m); |
292 | 294 |
316 | 318 |
317 m = KM_PATTERN.matcher(line); | 319 m = KM_PATTERN.matcher(line); |
318 | 320 |
319 if (!m.matches()) { | 321 if (!m.matches()) { |
320 log.warn( | 322 log.warn( |
321 "PRF: line 4 does not look like a PRF km extraction pattern."); | 323 "PRF: line 4 does not look like " |
324 + "a PRF km extraction pattern."); | |
322 return false; | 325 return false; |
323 } | 326 } |
324 | 327 |
325 KMFormat kmFormat = new KMFormat(m); | 328 KMFormat kmFormat = new KMFormat(m); |
326 | 329 |
354 double km; | 357 double km; |
355 try { | 358 try { |
356 km = kmFormat.extractKm(line); | 359 km = kmFormat.extractKm(line); |
357 } | 360 } |
358 catch (NumberFormatException iae) { | 361 catch (NumberFormatException iae) { |
359 log.warn("PRF: cannot extract km in line " + in.getLineNumber()); | 362 log.warn("PRF: cannot extract km in line " |
363 + in.getLineNumber()); | |
360 return false; | 364 return false; |
361 } | 365 } |
362 | 366 |
363 Double station = Double.valueOf(km); | 367 Double station = Double.valueOf(km); |
364 | 368 |
367 // When the station changed (no data yet in line) we expect | 371 // When the station changed (no data yet in line) we expect |
368 // skip/dummy lines to follow | 372 // skip/dummy lines to follow |
369 if (kmData == null) { | 373 if (kmData == null) { |
370 kmData = new ArrayList<XY>(); | 374 kmData = new ArrayList<XY>(); |
371 data.put(station, kmData); | 375 data.put(station, kmData); |
372 // When a station change occurs, dummy lines will occur, too. | 376 // When a station change occurs, |
377 // dummy lines will occur, too. | |
373 skip = lineSkipCount -1; | 378 skip = lineSkipCount -1; |
374 continue; | 379 continue; |
375 } | 380 } |
376 | 381 |
377 dataFormat.extractData(line, kmData); | 382 dataFormat.extractData(line, kmData); |
402 data.clear(); | 407 data.clear(); |
403 year = null; | 408 year = null; |
404 description = null; | 409 description = null; |
405 } | 410 } |
406 | 411 |
407 public void parsePRFs(File root, final CrossSectionParser.Callback callback) { | 412 public void parsePRFs( |
408 | 413 File root, |
414 final CrossSectionParser.Callback callback | |
415 ) { | |
409 FileTools.walkTree(root, new FileTools.FileVisitor() { | 416 FileTools.walkTree(root, new FileTools.FileVisitor() { |
410 @Override | 417 @Override |
411 public boolean visit(File file) { | 418 public boolean visit(File file) { |
412 if (file.isFile() && file.canRead() | 419 if (file.isFile() && file.canRead() |
413 && file.getName().toLowerCase().endsWith(".prf") | 420 && file.getName().toLowerCase().endsWith(".prf") |