[Dive4elements-commits] [PATCH 1 of 3] Correctly parse bedheights

Wald Commits scm-commit at wald.intevation.org
Wed Mar 27 11:49:02 CET 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1364381160 -3600
# Node ID 84beabb3897c3eae72cfc634525c7f304b0dd2b3
# Parent  13596605e81fe44ff6516312a704317871cb580f
Correctly parse bedheights.

diff -r 13596605e81f -r 84beabb3897c flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java
--- 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()
diff -r 13596605e81f -r 84beabb3897c flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java
--- 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();
diff -r 13596605e81f -r 84beabb3897c flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java
--- 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 :


More information about the Dive4elements-commits mailing list