diff src/java/de/intevation/mxd/writer/SymbolWriter.java @ 145:b2c5a66022f1

Exception handling for number conversions in writer modules.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 27 Jun 2011 18:22:21 +0200
parents 8f30f7e802d6
children 707f13cfba74
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/SymbolWriter.java	Mon Jun 27 17:22:52 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/SymbolWriter.java	Mon Jun 27 18:22:21 2011 +0200
@@ -97,8 +97,18 @@
 
     private void writeArrow(symbolObj symbol, Element symbolElement) {
         logger.debug("writeArrow(symbolObj, Element)");
-        double len = Double.parseDouble(symbolElement.getAttribute("length"));
-        double width = Double.parseDouble(symbolElement.getAttribute("width"));
+        double len = 0;
+        double width = 1;
+        try {
+            len =
+                Double.parseDouble(symbolElement.getAttribute("length"));
+            width =
+                Double.parseDouble(symbolElement.getAttribute("width"));
+        }
+        catch(NumberFormatException nfe) {
+            logger.warn ("Error setting arrow symbol.");
+            return;
+        }
         double ratio = len/width;
         lineObj points = new lineObj();
 
@@ -161,11 +171,11 @@
             String etype = elem.getAttribute("style");
             if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue () &&
                 etype.equals("point")) {
-                return i;   
+                return i;
             }
             else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue () &&
                     etype.equals("arrow")) {
-                return i;        
+                return i;
             }
             else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue () &&
                     etype.equals("char")) {
@@ -181,9 +191,8 @@
             }
             else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_HATCH.swigValue () &&
                     etype.equals("hatch")) {
-                return i;        
+                return i;
             }
-
         }
         return -1;
     }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)