Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/TkhColumnParser.java @ 8971:50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
author | mschaefer |
---|---|
date | Tue, 03 Apr 2018 10:18:30 +0200 |
parents | |
children | bf8a9df86f32 |
comparison
equal
deleted
inserted
replaced
8970:da5dc7446652 | 8971:50416a0df385 |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 | |
11 package org.dive4elements.river.importer.sinfo.parsers; | |
12 | |
13 import java.io.File; | |
14 | |
15 import org.apache.log4j.Logger; | |
16 import org.dive4elements.river.importer.ImportRiver; | |
17 import org.dive4elements.river.importer.common.AbstractParser; | |
18 import org.dive4elements.river.importer.sinfo.importitem.TkhColumnSeriesImport; | |
19 import org.dive4elements.river.importer.sinfo.importitem.TkhKmLineImport; | |
20 import org.dive4elements.river.importer.sinfo.importitem.TkhSeriesImport; | |
21 import org.dive4elements.river.model.sinfo.TkhColumn; | |
22 import org.dive4elements.river.model.sinfo.TkhValue; | |
23 | |
24 /** | |
25 * Reads and parses a column of a TKH file | |
26 * | |
27 * @author Matthias Schäfer | |
28 * | |
29 */ | |
30 public class TkhColumnParser extends AbstractParser<TkhColumn, TkhValue, TkhKmLineImport, TkhColumnSeriesImport> { | |
31 | |
32 /***** FIELDS *****/ | |
33 | |
34 private static final Logger log = Logger.getLogger(TkhColumnParser.class); | |
35 | |
36 private final TkhSeriesImport parent; | |
37 | |
38 private final int colIndex; | |
39 | |
40 private final String colName; | |
41 | |
42 | |
43 /***** CONSTRUCTORS *****/ | |
44 | |
45 public TkhColumnParser(final File importPath, final File rootRelativePath, final ImportRiver river, final TkhSeriesImport parent, final int colIndex, | |
46 final String colName) { | |
47 super(importPath, rootRelativePath, river); | |
48 this.parent = parent; | |
49 this.colIndex = colIndex; | |
50 this.colName = colName; | |
51 } | |
52 | |
53 | |
54 /***** METHODS *****/ | |
55 | |
56 @Override | |
57 protected Logger getLog() { | |
58 return log; | |
59 } | |
60 | |
61 @Override | |
62 protected void logStartInfo() { | |
63 getLog().info(String.format("Start parsing column %d '%s':;'%s'", this.colIndex, this.colName, this.rootRelativePath)); | |
64 } | |
65 | |
66 @Override | |
67 protected boolean handleMetaOther() { | |
68 // Skip any header line | |
69 return true; | |
70 } | |
71 | |
72 @Override | |
73 protected TkhColumnSeriesImport createSeriesImport(final String filename) { | |
74 return new TkhColumnSeriesImport(filename, this.parent, this.colName, this.rootRelativePath); | |
75 } | |
76 | |
77 @Override | |
78 protected TkhKmLineImport createKmLineImport(final Double km, final String[] values) { | |
79 // convert from cm to m | |
80 final double tkheight = parseDoubleWithNull(values[this.colIndex]).doubleValue() / 100.0; | |
81 return new TkhKmLineImport(km, tkheight); | |
82 } | |
83 } |