Mercurial > mxd2map
diff 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 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Tue May 31 15:37:19 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Tue May 31 17:54:43 2011 +0200 @@ -62,7 +62,8 @@ * * @return Currently always true. */ - public boolean write(Document doc) { + public boolean write(Document doc) + throws Exception { logger.debug("write()"); this.root = doc; @@ -138,7 +139,8 @@ /** * Create layer objects and set the attributes. */ - private void writeLayer() { + private void writeLayer() + throws Exception { logger.debug("writeLayer()"); Element mapNode = (Element)XMLUtils.xpath( root, @@ -192,7 +194,9 @@ * @param layer Mapscript layer object. * @param layerElement Dom element containing the class attributes. */ - private void writeClass(layerObj layer, Element layerElement) { + private void writeClass(layerObj layer, Element layerElement) + throws Exception { + logger.debug("writeClass(layerObj, Element)"); //Get all renderer elements (renderer in arcgis equals class in the //mapfile.) NodeList list = layerElement.getElementsByTagName("renderer"); @@ -216,7 +220,24 @@ co.setExpression(exp); } //Write symbols and styles. - writeSymbol(co, classElement); + NodeList slist = classElement.getElementsByTagName("symbol"); + String type = layerElement.getAttribute("type"); + if(type.equals("point")) { + for(int j = 0; j < slist.getLength(); j++){ + Element symbolElement = (Element) slist.item(j); + MarkerStyleWriter swriter = new MarkerStyleWriter (this.map, co); + swriter.write (symbolElement); + } + } + else if(type.equals("line")) { + for(int j = 0; j < slist.getLength(); j++){ + Element symbolElement = (Element) slist.item(j); + LineStyleWriter swriter = new LineStyleWriter (this.map, co); + swriter.write (symbolElement); + } + } + symbolSetObj symbolSet = map.getSymbolset(); + saveSymbolSet(symbolSet); } }