Mercurial > mxd2map
diff src/java/de/intevation/mxd/writer/MarkerStyleWriter.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 | 0bde090506f9 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MarkerStyleWriter.java Mon Jun 27 17:22:52 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MarkerStyleWriter.java Mon Jun 27 18:22:21 2011 +0200 @@ -43,8 +43,14 @@ symbolSetObj symbolSet = map.getSymbolset(); if (symbolElement.hasAttribute("angle")) { - style.setAngle( - Double.parseDouble(symbolElement.getAttribute("angle"))); + try { + style.setAngle( + Double.parseDouble(symbolElement.getAttribute("angle"))); + } + catch(NumberFormatException nfe) { + logger.warn("Error setting angle."); + style.setAngle(0.0); + } } if(symbolElement.hasAttribute("color")) { String c = symbolElement.getAttribute("color"); @@ -57,8 +63,14 @@ style.setColor(color); } if (symbolElement.hasAttribute ("size")) { - style.setSize(Double.parseDouble( - symbolElement.getAttribute("size"))); + try { + style.setSize(Double.parseDouble( + symbolElement.getAttribute("size"))); + } + catch(NumberFormatException nfe) { + logger.warn("Error setting size. Setting to deafult: 1."); + style.setSize(1); + } } if(symbolElement.hasAttribute("outline_color")) { Color oCol = Color.decode( @@ -69,8 +81,13 @@ oCol.getBlue(), -4); style.setOutlinecolor(outlineColor); - style.setOutlinewidth(Double.parseDouble( - symbolElement.getAttribute("outline_size"))); + try { + style.setOutlinewidth(Double.parseDouble( + symbolElement.getAttribute("outline_size"))); + } + catch(NumberFormatException nfe) { + logger.warn("Error setting outline width."); + } } String symType = symbolElement.getAttribute("style"); if(symType.equals("point") || @@ -85,7 +102,6 @@ String name = symbolElement.getAttribute("name"); style.setSymbolByName(map, name); - return true; } }