changeset 4746:0b60b77d4d00

DA66Parser: Handle coding convention that was introduced to overcome fixed length fields.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 03 Jan 2013 09:57:22 +0100
parents c10103dc202f
children 2a6d64a415e4
files flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java	Thu Jan 03 09:56:43 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java	Thu Jan 03 09:57:22 2013 +0100
@@ -252,6 +252,42 @@
         }
     }
 
+    /** Apply the convention how to deal with numbers < -99.999 .*/
+    private String applyLetterConvention(String orig) {
+        if (orig.endsWith("-")) {
+            return "-" + orig.replace("-","");
+        }
+        else if (orig.endsWith("J")) {
+            return "-" + orig.replace("J","1");
+        }
+        else if (orig.endsWith("K")) {
+            return "-" + orig.replace("K","2");
+        }
+        else if (orig.endsWith("L")) {
+            return "-" + orig.replace("L","3");
+        }
+        else if (orig.endsWith("M")) {
+            return "-" + orig.replace("M","4");
+        }
+        else if (orig.endsWith("N")) {
+            return "-" + orig.replace("N","5");
+        }
+        else if (orig.endsWith("O")) {
+            return "-" + orig.replace("O","6");
+        }
+        else if (orig.endsWith("P")) {
+            return "-" + orig.replace("P","7");
+        }
+        else if (orig.endsWith("Q")) {
+            return "-" + orig.replace("Q","8");
+        }
+        else if (orig.endsWith("R")) {
+            return "-" + orig.replace("R","9");
+        }
+        else {
+            return orig;
+        }
+    }
 
     /**
      * Add a Point (YZ,Index) to the current cross section line.
@@ -269,6 +305,8 @@
 
         double iy;
         double iz;
+        // Handle letter convention.
+        y = applyLetterConvention(y);
         try {
             iy = Double.parseDouble(y) / 1000d;
             iz = Double.parseDouble(z) / 1000d;

http://dive4elements.wald.intevation.org