comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 87:7d4cf2db43f1

Added new writer classes to be flexible in creating mapfiles.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 31 May 2011 17:54:43 +0200
parents e468cf8701ea
children df2eb0e7d229
comparison
equal deleted inserted replaced
86:e19c5eb43099 87:7d4cf2db43f1
60 * Write the mapfile. 60 * Write the mapfile.
61 * @param doc The root document containin the map attributes. 61 * @param doc The root document containin the map attributes.
62 * 62 *
63 * @return Currently always true. 63 * @return Currently always true.
64 */ 64 */
65 public boolean write(Document doc) { 65 public boolean write(Document doc)
66 throws Exception {
66 logger.debug("write()"); 67 logger.debug("write()");
67 this.root = doc; 68 this.root = doc;
68 69
69 //Get the filename. 70 //Get the filename.
70 Element fileNode = (Element)XMLUtils.xpath( 71 Element fileNode = (Element)XMLUtils.xpath(
136 } 137 }
137 138
138 /** 139 /**
139 * Create layer objects and set the attributes. 140 * Create layer objects and set the attributes.
140 */ 141 */
141 private void writeLayer() { 142 private void writeLayer()
143 throws Exception {
142 logger.debug("writeLayer()"); 144 logger.debug("writeLayer()");
143 Element mapNode = (Element)XMLUtils.xpath( 145 Element mapNode = (Element)XMLUtils.xpath(
144 root, 146 root,
145 "/mxd/map", 147 "/mxd/map",
146 XPathConstants.NODE); 148 XPathConstants.NODE);
190 /** 192 /**
191 * Adds the classes to the layer. 193 * Adds the classes to the layer.
192 * @param layer Mapscript layer object. 194 * @param layer Mapscript layer object.
193 * @param layerElement Dom element containing the class attributes. 195 * @param layerElement Dom element containing the class attributes.
194 */ 196 */
195 private void writeClass(layerObj layer, Element layerElement) { 197 private void writeClass(layerObj layer, Element layerElement)
198 throws Exception {
199 logger.debug("writeClass(layerObj, Element)");
196 //Get all renderer elements (renderer in arcgis equals class in the 200 //Get all renderer elements (renderer in arcgis equals class in the
197 //mapfile.) 201 //mapfile.)
198 NodeList list = layerElement.getElementsByTagName("renderer"); 202 NodeList list = layerElement.getElementsByTagName("renderer");
199 203
200 //Create all found class objects and write the symbols and styles for 204 //Create all found class objects and write the symbols and styles for
214 exp += " " + classElement.getAttribute("value") + ")"; 218 exp += " " + classElement.getAttribute("value") + ")";
215 } 219 }
216 co.setExpression(exp); 220 co.setExpression(exp);
217 } 221 }
218 //Write symbols and styles. 222 //Write symbols and styles.
219 writeSymbol(co, classElement); 223 NodeList slist = classElement.getElementsByTagName("symbol");
224 String type = layerElement.getAttribute("type");
225 if(type.equals("point")) {
226 for(int j = 0; j < slist.getLength(); j++){
227 Element symbolElement = (Element) slist.item(j);
228 MarkerStyleWriter swriter = new MarkerStyleWriter (this.map, co);
229 swriter.write (symbolElement);
230 }
231 }
232 else if(type.equals("line")) {
233 for(int j = 0; j < slist.getLength(); j++){
234 Element symbolElement = (Element) slist.item(j);
235 LineStyleWriter swriter = new LineStyleWriter (this.map, co);
236 swriter.write (symbolElement);
237 }
238 }
239 symbolSetObj symbolSet = map.getSymbolset();
240 saveSymbolSet(symbolSet);
220 } 241 }
221 } 242 }
222 243
223 /** 244 /**
224 * Adds the symbols and styles to the mapfile. 245 * Adds the symbols and styles to the mapfile.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)