Mercurial > mxd2map
comparison 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 |
comparison
equal
deleted
inserted
replaced
53:691864097eb1 | 55:f0c02ff120d6 |
---|---|
42 /** | 42 /** |
43 * Private member. | 43 * Private member. |
44 */ | 44 */ |
45 private Document root; | 45 private Document root; |
46 private mapObj map; | 46 private mapObj map; |
47 | 47 private String mapFilename; |
48 | 48 |
49 /** | |
50 * TODO: Workarround to import the Mapfile-Template, it should be done | |
51 * via a property file, currently hardcoded. | |
52 */ | |
53 public MapScriptWriter() { | 49 public MapScriptWriter() { |
54 map = new mapObj("z:/mxd-testbed_sh/mapserver/mapfile/mxd.map"); | 50 map = new mapObj(""); |
55 } | 51 mapFilename = ""; |
56 | 52 } |
57 public MapScriptWriter(String path) { | 53 |
58 map = new mapObj(path); | 54 public MapScriptWriter(String templ, String filename) { |
55 map = new mapObj(templ); | |
56 mapFilename = filename; | |
59 } | 57 } |
60 | 58 |
61 /** | 59 /** |
62 * Write the mapfile. | 60 * Write the mapfile. |
63 * @param doc The root document containin the map attributes. | 61 * @param doc The root document containin the map attributes. |
71 //Get the filename. | 69 //Get the filename. |
72 Element fileNode = (Element)XMLUtils.xpath( | 70 Element fileNode = (Element)XMLUtils.xpath( |
73 root, | 71 root, |
74 "/mxd/file", | 72 "/mxd/file", |
75 XPathConstants.NODE); | 73 XPathConstants.NODE); |
76 String filename = fileNode.getAttribute("name"); | |
77 if(filename.endsWith(".mxd")) { | |
78 filename = filename.replace(".mxd", ".map"); | |
79 } | |
80 //Write the map attributes. | 74 //Write the map attributes. |
81 writeMap(); | 75 writeMap(); |
82 //Write the layers. | 76 //Write the layers. |
83 writeLayer(); | 77 writeLayer(); |
84 //Save the map. | 78 //Save the map. |
85 mapObj cloneMap = map.cloneMap(); | 79 mapObj cloneMap = map.cloneMap(); |
86 cloneMap.save(filename); | 80 cloneMap.save(mapFilename); |
87 return true; | 81 return true; |
88 } | 82 } |
89 | 83 |
90 /** | 84 /** |
91 * Create the map object and set the attributes. | 85 * Create the map object and set the attributes. |
240 for(int i = 0; i < list.getLength(); i++){ | 234 for(int i = 0; i < list.getLength(); i++){ |
241 Element symbolElement = (Element) list.item(i); | 235 Element symbolElement = (Element) list.item(i); |
242 styleObj style = new styleObj(co); | 236 styleObj style = new styleObj(co); |
243 style.setAngle( | 237 style.setAngle( |
244 Double.parseDouble(symbolElement.getAttribute("angle"))); | 238 Double.parseDouble(symbolElement.getAttribute("angle"))); |
245 String c = symbolElement.getAttribute("color"); | 239 if(symbolElement.hasAttribute("color")) { |
246 Color col = Color.decode(c); | 240 String c = symbolElement.getAttribute("color"); |
247 colorObj color = new colorObj( | 241 Color col = Color.decode(c); |
248 col.getRed(), | 242 colorObj color = new colorObj( |
249 col.getGreen(), | 243 col.getRed(), |
250 col.getBlue(), | 244 col.getGreen(), |
251 -4); | 245 col.getBlue(), |
252 style.setColor(color); | 246 -4); |
247 style.setColor(color); | |
248 } | |
253 style.setSize(Double.parseDouble( | 249 style.setSize(Double.parseDouble( |
254 symbolElement.getAttribute("size"))); | 250 symbolElement.getAttribute("size"))); |
255 if(symbolElement.hasAttribute("outline_color")) { | 251 if(symbolElement.hasAttribute("outline_color")) { |
256 Color oCol = Color.decode( | 252 Color oCol = Color.decode( |
257 symbolElement.getAttribute("outline_color")); | 253 symbolElement.getAttribute("outline_color")); |