Mercurial > mxd2map
diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 62:e468cf8701ea
Prepared the converter to handle and write line symbols.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 24 May 2011 14:16:25 +0200 |
parents | ef1ee8e752b2 |
children | 7d4cf2db43f1 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Mon May 23 13:16:42 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Tue May 24 14:16:25 2011 +0200 @@ -174,6 +174,9 @@ if(type.equals("point")) { layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT); } + else if (type.equals("line")) { + layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE); + } //The layer datasource. layer.setData(layerElement.getAttribute("data_source")); @@ -230,12 +233,13 @@ //Get the symbol set from the map object. symbolSetObj symbolSet = map.getSymbolset(); - // for(int i = 0; i < list.getLength(); i++){ Element symbolElement = (Element) list.item(i); styleObj style = new styleObj(co); - style.setAngle( - Double.parseDouble(symbolElement.getAttribute("angle"))); + if (symbolElement.hasAttribute("angle")) { + style.setAngle( + Double.parseDouble(symbolElement.getAttribute("angle"))); + } if(symbolElement.hasAttribute("color")) { String c = symbolElement.getAttribute("color"); Color col = Color.decode(c); @@ -246,8 +250,10 @@ -4); style.setColor(color); } - style.setSize(Double.parseDouble( - symbolElement.getAttribute("size"))); + if (symbolElement.hasAttribute ("size")) { + style.setSize(Double.parseDouble( + symbolElement.getAttribute("size"))); + } if(symbolElement.hasAttribute("outline_color")) { Color oCol = Color.decode( symbolElement.getAttribute("outline_color")); @@ -260,10 +266,26 @@ style.setOutlinewidth(Double.parseDouble( symbolElement.getAttribute("outline_size"))); } + //Section for line symbols + //Setting the width + if(symbolElement.hasAttribute("width")) { + style.setWidth((int)Double.parseDouble( + symbolElement.getAttribute("width"))); + } String name = symbolElement.getAttribute("name"); style.setSymbolByName(map, name); symbolObj sym = symbolSet.getSymbolByName(name); + //The following lines are for dashed and/or dotted lines. + //These lines throw an "incorrect array size" error. + //TODO Find out how to set the pattern correctly. +// style.setPatternlength(2); +// double[] vals = new double[] {1.0, 2.0, 3.0}; +// vals[0] = 1.0; +// vals[1] = 2.0; +// vals[2] = 3.0; +// vals[3] = 4.0; +// style.setPattern(vals); String symType = symbolElement.getAttribute("style"); if(symType.equals("point")) { writePointSymbol(sym, symbolElement); @@ -274,6 +296,9 @@ else if (symType.equals("char")) { writeCharSymbol(sym, symbolElement); } + else if(symType.equals("line")) { + writeSimpleLineSymbol(sym, symbolElement); + } } saveSymbolSet(symbolSet); } @@ -328,6 +353,18 @@ } + private void writeSimpleLineSymbol( + symbolObj symbol, + Element symbolElement) { + logger.debug("writeSimpleLineSymbol()"); + symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_SIMPLE.swigValue()); + String ls = symbolElement.getAttribute("linestyle"); + if(ls.equals("solid")) { + symbol.setFilled(1); + } + } + + /** * Save the symbol set. * @param symbols The symbol set. @@ -337,7 +374,6 @@ root, "/mxd/file", XPathConstants.NODE); - String mapFilename = fileNode.getAttribute("name"); String path = ""; if(mapFilename.contains("/")) { path = mapFilename.substring(0, mapFilename.lastIndexOf("/"));