Mercurial > mxd2map
view src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 29:77cfa8092611
Write FeatureLayer attributes to XML document.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 08 Apr 2011 17:36:22 +0200 |
parents | 3e24fffdf2bb |
children | 40c0b4e5f91a |
line wrap: on
line source
//package de.intevation.mxd.reader; import java.io.IOException; import org.apache.log4j.Logger; import com.esri.arcgis.carto.ILayer; import com.esri.arcgis.carto.FeatureLayer; import com.esri.arcgis.geometry.ISpatialReference; import com.esri.arcgis.geometry.ProjectedCoordinateSystem; import com.esri.arcgis.geometry.IProjection; import com.esri.arcgis.geometry.Projection; import com.esri.arcgis.display.ISymbol; import com.esri.arcgis.display.SimpleMarkerSymbol; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * Reads Layer information.. * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class FeatureLayerReader implements ILayerReader{ private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); private FeatureLayer layer; private Document document; //Constructor 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()); } //Methods /** * Setter for XML document. */ public void setDocument(Document doc){ this.document = doc; } /** * Reads the Layer content. */ public boolean read() throws IOException{ logger.debug("read()"); XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document, "", ""); Element layerElement = creator.create("layer"); creator.addAttr(layerElement, "name", layer.getName()); creator.addAttr(layerElement, "min_scale", String.valueOf(layer.getMinimumScale())); creator.addAttr(layerElement, "max_scale", String.valueOf(layer.getMaximumScale())); if(layer.isVisible()) creator.addAttr(layerElement, "status", "on"); else creator.addAttr(layerElement, "status", "off"); creator.addAttr(layerElement, "definition_query", layer.getDefinitionExpression()); NodeList list = document.getElementsByTagName("map"); if(list.getLength() > 1){ throw new IOException("Error while creating DOM! Found" + " more than one map object!"); } else{ Node map = list.item(0); map.appendChild(layerElement); } return true; } public void getLayer() throws IOException{ logger.debug("getLayer() -> not implemented jet."); return; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :