Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java @ 5507:db6c7268b08e
Schema change: add shore offset to sediment density values and be more rigid with input files in parser
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Thu, 28 Mar 2013 16:41:30 +0100 |
parents | 1b036a409575 |
children | c6e552348934 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java Thu Mar 28 15:55:34 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java Thu Mar 28 16:41:30 2013 +0100 @@ -85,27 +85,12 @@ if (handleMetaDepth(line)) { return; } - else if (handleMetaColumns(line)) { - return; - } else { log.warn("Unknown meta line: '" + line + "'"); } } - private boolean handleMetaColumns(String line) { - String[] columns = line.split(";"); - for (int i = 0; i < columns.length; i++) { - if (columns[i].contains("Sedimentdichte")) { - this.densitsyColumn = i; - return true; - } - } - return false; - } - - protected boolean handleMetaDepth(String line) { Matcher m = META_DEPTH.matcher(line); @@ -145,18 +130,25 @@ return; } - BigDecimal km; - BigDecimal density; + BigDecimal km = null; + BigDecimal shoreOffset = null; + BigDecimal density = null; try { - km = new BigDecimal(nf.parse(vals[0]).doubleValue()); - density = new BigDecimal(nf.parse(vals[this.densitsyColumn]).doubleValue()); - + km = new BigDecimal(nf.parse(vals[0]).doubleValue()); + density = new BigDecimal(nf.parse(vals[2]).doubleValue()); + if (!vals[1].isEmpty()) { + shoreOffset = new BigDecimal(nf.parse(vals[1]).doubleValue()); + } } catch (ParseException pe) { log.warn("Unparseable numbers in '" + line + "'"); - return; } + if (km == null || density == null) { + log.warn("SDP: No km nor density given. Skip line"); + return; + } + BigDecimal year = null; try { year = @@ -176,9 +168,10 @@ current.addValue(new ImportSedimentDensityValue( km, + shoreOffset, density, year, - vals[vals.length - 1]) + currentDescription) ); }