Mercurial > dive4elements > river
changeset 5450:84beabb3897c
Correctly parse bedheights.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 27 Mar 2013 11:46:00 +0100 (2013-03-27) |
parents | 13596605e81f |
children | 278d8759c92b |
files | flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java |
diffstat | 3 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java Tue Mar 26 14:02:58 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java Wed Mar 27 11:46:00 2013 +0100 @@ -158,8 +158,7 @@ Range theRange = range != null ? range.getPeer(river) : null; if (theRange == null) { - log.warn("BHE: Skip file - invalid km range."); - return null; + log.warn("BHE: invalid km range."); } Session session = ImporterSession.getInstance()
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java Tue Mar 26 14:02:58 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java Wed Mar 27 11:46:00 2013 +0100 @@ -151,9 +151,8 @@ } if (theRange == null) { - log.warn("BHS: No km-range given. Skip file '" + + log.warn("BHS: No km-range given: '" + description + "'"); - return null; } Session session = ImporterSession.getInstance().getDatabaseSession();
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java Tue Mar 26 14:02:58 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java Wed Mar 27 11:46:00 2013 +0100 @@ -75,7 +75,7 @@ new BigDecimal(nf.parse(values[1]).doubleValue()), new BigDecimal(nf.parse(values[2]).doubleValue()), new BigDecimal(nf.parse(values[3]).doubleValue()), - new BigDecimal(nf.parse(values[4]).doubleValue()), + parseBigDecimal(values[4], line), new BigDecimal(nf.parse(values[5]).doubleValue()) ); @@ -85,5 +85,21 @@ log.warn("BSP: Error while parsing data row.", e); } } + + private BigDecimal parseBigDecimal(String value, String line) { + BigDecimal result = null; + try { + Double dValue = Double.valueOf(value.replace(",", ".")); + result = new BigDecimal(dValue.doubleValue()); + } + catch (NumberFormatException nfe) { + log.warn( + "Error parsing " + + value + + " in bed heigt single row: " + + line); + } + return result; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :