[Dive4elements-commits] [PATCH 04 of 11] DA66Parser: Try to guess whether station is given in km or in cm

Wald Commits scm-commit at wald.intevation.org
Thu Dec 27 16:10:30 CET 2012


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1356610404 -3600
# Node ID 9f7cd65daac21a263692e61ff2ea145726bc8501
# Parent  7a8d3ec7abbc9b3ee342f8b9641b3fbb8e5233d6
DA66Parser: Try to guess whether station is given in km or in cm.

diff -r 7a8d3ec7abbc -r 9f7cd65daac2 flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java	Thu Dec 27 13:13:05 2012 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java	Thu Dec 27 13:13:24 2012 +0100
@@ -245,6 +245,17 @@
     }
 
 
+    /** Returns station, deciding if it could in cm, in which case convert. */
+    private double stationInKm(double station) {
+        if (station > 10000) {
+            return station/100000d;
+        }
+        else {
+            return station;
+        }
+    }
+
+
     /**
      * Add a Point (YZ,Index) to the current cross section line.
      * @param y The y coordinate of new point.
@@ -303,8 +314,8 @@
                 if (m.find()) {
                     // Actually matches!
                     currentLine = new ArrayList<XY>();
-                    data.put(Double.parseDouble(m.group(FIELD.STATION.getIdx())),
-                        currentLine);
+                    double station = stationInKm(Double.parseDouble(m.group(FIELD.STATION.getIdx())));
+                    data.put(station, currentLine);
                 }
                 else {
                     logger.error("HEAD line bad.");


More information about the Dive4elements-commits mailing list