view src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 31:40c0b4e5f91a

Added utility class to store map attributes.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 11 Apr 2011 16:04:03 +0200
parents 77cfa8092611
children c51376f8e24c
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{

    /**
     * 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 IOException {
        logger.debug("read()");
        Element layerElement;
        try {
            layerElement = util.addLayer();
        }
        catch(Exception e) {
            e.printStackTrace();
            return null;
        }

        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");
        }

        layerElement.setAttribute("definition_query",
            layer.getDefinitionExpression());

        return layerElement;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)