comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/FlowDepthColumnParser.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 31549fdfaf4f
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.common.ParsingState;
19 import org.dive4elements.river.importer.sinfo.importitem.FlowDepthColumnSeriesImport;
20 import org.dive4elements.river.importer.sinfo.importitem.FlowDepthKmLineImport;
21 import org.dive4elements.river.importer.sinfo.importitem.FlowDepthSeriesImport;
22 import org.dive4elements.river.model.sinfo.FlowDepthColumn;
23 import org.dive4elements.river.model.sinfo.FlowDepthValue;
24
25 /**
26 * Reads and parses a column of a flow depth file
27 *
28 * @author Matthias Schäfer
29 *
30 */
31 public class FlowDepthColumnParser extends AbstractParser<FlowDepthColumn, FlowDepthValue, FlowDepthKmLineImport, FlowDepthColumnSeriesImport> {
32
33 /***** FIELDS *****/
34
35 private static final Logger log = Logger.getLogger(FlowDepthColumnParser.class);
36
37 private final FlowDepthSeriesImport parent;
38
39 private final int colIndex;
40
41 private final String colName;
42
43
44 /***** CONSTRUCTORS *****/
45
46 public FlowDepthColumnParser(final File importPath, final File rootRelativePath, final ImportRiver river, final FlowDepthSeriesImport parent,
47 final int colIndex,
48 final String colName) {
49 super(importPath, rootRelativePath, river);
50 this.parent = parent;
51 this.colIndex = colIndex;
52 this.colName = colName;
53 }
54
55
56 /***** METHODS *****/
57
58 @Override
59 protected Logger getLog() {
60 return log;
61 }
62
63 @Override
64 protected void logStartInfo() {
65 getLog().info(String.format("Start parsing column %d '%s':;'%s'", this.colIndex, this.colName, this.rootRelativePath));
66 }
67
68 @Override
69 protected boolean handleMetaOther() {
70 this.headerParsingState = ParsingState.IGNORE;
71 return false;
72 }
73
74 @Override
75 protected FlowDepthColumnSeriesImport createSeriesImport(final String filename) {
76 return new FlowDepthColumnSeriesImport(filename, this.parent, this.colName, this.rootRelativePath);
77 }
78
79 @Override
80 protected FlowDepthKmLineImport createKmLineImport(final Double km, final String[] values) {
81 final double tkheight = parseDoubleWithNull(values[this.colIndex]).doubleValue();
82 return new FlowDepthKmLineImport(km, tkheight);
83 }
84 }

http://dive4elements.wald.intevation.org