Mercurial > dive4elements > river
diff backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java @ 7862:cdef048c4ac5
Fixed porosity importer. Find existing db entries and parse values from string, not via double.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 08 May 2014 13:48:45 +0200 |
parents | 02711de579cc |
children | d9d2bd78eff6 |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java Thu May 08 13:46:32 2014 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java Thu May 08 13:48:45 2014 +0200 @@ -137,19 +137,22 @@ log.info("Found porosity depth: " + lo + " - " + up + " cm"); + ImportDepth depth = null; try { - ImportDepth depth = new ImportDepth( - new BigDecimal(nf.parse(lo).doubleValue()), - new BigDecimal(nf.parse(up).doubleValue()) + depth = new ImportDepth( + new BigDecimal(lo), + new BigDecimal(up) ); + } + catch (NumberFormatException nfe) { + log.warn("Unparsable number for depth: " + line, nfe); + } + if (depth != null) { current.setDepth(depth); - return true; } - catch (ParseException pe) { - log.warn("Unparseable numbers in: '" + line + "'"); - } + return false; } else { log.debug("Meta line doesn't contain depth information: " + line); @@ -170,15 +173,18 @@ BigDecimal km = null; BigDecimal shoreOffset = null; BigDecimal porosity = null; + vals[0] = vals[0].replace(",", "."); + vals[2] = vals[2].replace(",", "."); try { - km = new BigDecimal(nf.parse(vals[0]).doubleValue()); - porosity = new BigDecimal(nf.parse(vals[2]).doubleValue()); + km = new BigDecimal(vals[0]); + porosity = new BigDecimal(vals[2]); if (!vals[1].isEmpty()) { - shoreOffset = new BigDecimal(nf.parse(vals[1]).doubleValue()); + vals[1] = vals[1].replace(",", "."); + shoreOffset = new BigDecimal(vals[1]); } } - catch (ParseException pe) { - log.warn("Unparseable numbers in '" + line + "'"); + catch(NumberFormatException nfe) { + log.warn("Unparsable number in line: " + line, nfe); } if (km == null || porosity == null) {