Mercurial > mxd2map
diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 55:f0c02ff120d6
Read filenames from properties file or commandline arguments.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 16 May 2011 18:21:27 +0200 |
parents | 691864097eb1 |
children | 8da6555f1c12 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed May 11 10:10:18 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Mon May 16 18:21:27 2011 +0200 @@ -44,18 +44,16 @@ */ private Document root; private mapObj map; - + private String mapFilename; - /** - * TODO: Workarround to import the Mapfile-Template, it should be done - * via a property file, currently hardcoded. - */ public MapScriptWriter() { - map = new mapObj("z:/mxd-testbed_sh/mapserver/mapfile/mxd.map"); + map = new mapObj(""); + mapFilename = ""; } - public MapScriptWriter(String path) { - map = new mapObj(path); + public MapScriptWriter(String templ, String filename) { + map = new mapObj(templ); + mapFilename = filename; } /** @@ -73,17 +71,13 @@ root, "/mxd/file", XPathConstants.NODE); - String filename = fileNode.getAttribute("name"); - if(filename.endsWith(".mxd")) { - filename = filename.replace(".mxd", ".map"); - } //Write the map attributes. writeMap(); //Write the layers. writeLayer(); //Save the map. mapObj cloneMap = map.cloneMap(); - cloneMap.save(filename); + cloneMap.save(mapFilename); return true; } @@ -242,14 +236,16 @@ styleObj style = new styleObj(co); style.setAngle( Double.parseDouble(symbolElement.getAttribute("angle"))); - String c = symbolElement.getAttribute("color"); - Color col = Color.decode(c); - colorObj color = new colorObj( - col.getRed(), - col.getGreen(), - col.getBlue(), - -4); - style.setColor(color); + if(symbolElement.hasAttribute("color")) { + String c = symbolElement.getAttribute("color"); + Color col = Color.decode(c); + colorObj color = new colorObj( + col.getRed(), + col.getGreen(), + col.getBlue(), + -4); + style.setColor(color); + } style.setSize(Double.parseDouble( symbolElement.getAttribute("size"))); if(symbolElement.hasAttribute("outline_color")) {