Mercurial > mxd2map
view src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 102:3ca2ec55fb3b
Set TILEITEM to an empty string.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 11:35:41 +0200 |
parents | bab3946a8bdc |
children | 0db6eacad0e6 |
line wrap: on
line source
package de.intevation.mxd.reader; import org.apache.log4j.Logger; import com.esri.arcgis.carto.ILayer; import com.esri.arcgis.carto.FeatureLayer; import com.esri.arcgis.geodatabase.FeatureClassName; import com.esri.arcgis.system.IName; import org.w3c.dom.Element; import de.intevation.mxd.utils.MapToXMLUtils; /** * Reads Layer information. * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class FeatureLayerReader implements ILayerReader { /** * The logger. */ private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); /** * Privte member. */ private FeatureLayer layer; private MapToXMLUtils util; public FeatureLayerReader(ILayer layer) throws Exception { if(layer instanceof FeatureLayer) { this.layer = (FeatureLayer)layer; } else { throw new Exception("Not an instance of FeatureLayer: " + layer.getClass().toString()); } } /** * Setter for XML document helper. * * @param util The helper for storing map information. */ public void setUtil(MapToXMLUtils util) { this.util = util; } /** * Reads the Layer content. * * @return The layer XML element. */ public Element read() throws Exception { logger.debug("read()"); Element layerElement = util.addLayer(); layerElement.setAttribute("name", layer.getName()); layerElement.setAttribute("min_scale", String.valueOf(layer.getMinimumScale())); layerElement.setAttribute("max_scale", String.valueOf(layer.getMaximumScale())); if(layer.isVisible()) { layerElement.setAttribute("status", "on"); } else { layerElement.setAttribute("status", "off"); } int type = layer.getShapeType(); switch (type) { case 0: layerElement.setAttribute("type", "none"); break; case 1: layerElement.setAttribute("type", "point"); break; case 3: layerElement.setAttribute("type", "line"); break; case 4: layerElement.setAttribute("type", "polygon"); break; } layerElement.setAttribute("definition_query", layer.getDefinitionExpression()); IName fcn = layer.getDataSourceName(); if(fcn instanceof FeatureClassName) { FeatureClassName name = (FeatureClassName)fcn; layerElement.setAttribute("data_source", name.getName()); } else { logger.debug ("Unknown FeatureClass name:" + fcn.getClass().toString()); } String datatype = layer.getDataSourceType(); if(datatype.equals("Shapefile Feature Class")) { layerElement.setAttribute("connection_type", "local"); layerElement.setAttribute( "workspace", layer.getWorkspace().getPathName()); } else if(datatype.equals("File Geodatabase Feature Class")){ layerElement.setAttribute("connection_type", "ogr"); layerElement.setAttribute("data", layer.getFeatureClass().getFeatureDataset().getName()); layerElement.setAttribute( "workspace", layer.getWorkspace().getPathName()); } else if(datatype.equals("SDE Feature Class")) { //TODO Read SDE data settings } return layerElement; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :