comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 106:609c234e8e23

merged with reimunds changes
author Stephan Holl <stephan.holl@intevation.de>
date Tue, 07 Jun 2011 15:50:43 +0200
parents 4696d0769f9c
children d6d2a4058ebf
comparison
equal deleted inserted replaced
105:db18c1b33936 106:609c234e8e23
4 4
5 import org.w3c.dom.Document; 5 import org.w3c.dom.Document;
6 import org.w3c.dom.Element; 6 import org.w3c.dom.Element;
7 import org.w3c.dom.NodeList; 7 import org.w3c.dom.NodeList;
8 8
9 import java.io.File;
10
9 import javax.xml.xpath.XPathConstants; 11 import javax.xml.xpath.XPathConstants;
10 import java.awt.Color;
11 12
12 import edu.umn.gis.mapscript.mapObj; 13 import edu.umn.gis.mapscript.mapObj;
13 import edu.umn.gis.mapscript.layerObj; 14 import edu.umn.gis.mapscript.layerObj;
14 import edu.umn.gis.mapscript.classObj; 15 import edu.umn.gis.mapscript.classObj;
15 import edu.umn.gis.mapscript.styleObj;
16 import edu.umn.gis.mapscript.colorObj;
17 import edu.umn.gis.mapscript.symbolObj;
18 import edu.umn.gis.mapscript.symbolSetObj;
19 import edu.umn.gis.mapscript.lineObj;
20 import edu.umn.gis.mapscript.pointObj;
21 16
22 import edu.umn.gis.mapscript.MS_UNITS; 17 import edu.umn.gis.mapscript.MS_UNITS;
23 import edu.umn.gis.mapscript.MS_LAYER_TYPE; 18 import edu.umn.gis.mapscript.MS_LAYER_TYPE;
24 import edu.umn.gis.mapscript.MS_SYMBOL_TYPE;
25 19
26 import de.intevation.mxd.utils.XMLUtils; 20 import de.intevation.mxd.utils.XMLUtils;
27 21
28 /** 22 /**
29 * The Mapfile Writer. 23 * The Mapfile Writer.
177 layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT); 171 layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT);
178 } 172 }
179 else if (type.equals("line")) { 173 else if (type.equals("line")) {
180 layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE); 174 layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE);
181 } 175 }
176 else if (type.equals("polygon")) {
177 layer.setType(MS_LAYER_TYPE.MS_LAYER_POLYGON);
178 }
182 179
183 //The layer datasource. 180 //The layer datasource.
184 layer.setData(layerElement.getAttribute("data_source")); 181 String datasource = "";
182 if(layerElement.hasAttribute("workspace")) {
183 datasource = layerElement.getAttribute("workspace");
184 datasource += File.separator;
185 }
186 datasource += layerElement.getAttribute("data_source");
187 layer.setData(datasource);
185 188
186 //Write classes. 189 //Write classes.
187 writeClass(layer, layerElement); 190 writeClass(layer, layerElement);
188 } 191 }
189 192
218 exp += " " + classElement.getAttribute("value") + ")"; 221 exp += " " + classElement.getAttribute("value") + ")";
219 } 222 }
220 co.setExpression(exp); 223 co.setExpression(exp);
221 } 224 }
222 //Write symbols and styles. 225 //Write symbols and styles.
223 NodeList slist = classElement.getElementsByTagName("symbol"); 226 NodeList l = classElement.getChildNodes();
224 String type = layerElement.getAttribute("type"); 227 for (int j = 0; j < l.getLength(); j++) {
225 if(type.equals("point")) { 228 Element elem = (Element)l.item(j);
226 for(int j = 0; j < slist.getLength(); j++){ 229
227 Element symbolElement = (Element) slist.item(j); 230 String type = layerElement.getAttribute("type");
231 if(type.equals("point") && elem.getTagName().equals("symbol")) {
228 MarkerStyleWriter swriter = new MarkerStyleWriter (this.map, co); 232 MarkerStyleWriter swriter = new MarkerStyleWriter (this.map, co);
229 swriter.write (symbolElement); 233 swriter.write (elem);
230 } 234 }
231 } 235 else if(type.equals("line") && elem.getTagName().equals("symbol")) {
232 else if(type.equals("line")) { 236 LineStyleWriter swriter = new LineStyleWriter (this.map, co);
233 for(int j = 0; j < slist.getLength(); j++){ 237 swriter.write (elem);
234 Element symbolElement = (Element) slist.item(j); 238 }
235 // LineStyleWriter swriter = new LineStyleWriter (this.map, co); 239 else if(type.equals("polygon") && elem.getTagName().equals("symbol")) {
236 // swriter.write (symbolElement); 240 FillStyleWriter swriter = new FillStyleWriter (this.map, co);
241 swriter.write (elem);
237 } 242 }
238 } 243 }
239 } 244 }
240 } 245 }
241 } 246 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)