Mercurial > mxd2map
view src/java/de/intevation/mxd/reader/WMSGroupLayerReader.java @ 340:dbfcb0b69a63
* contrib/installer/example/example/template.map: Switch to latin1 encoding
* contrib/installer/example/example/mapfile_header.include: Remove shapepath,
data is now referenced relative to the mapfile
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 09 Nov 2012 16:54:16 +0100 |
parents | 2cb2d8eb56ed |
children |
line wrap: on
line source
/* * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> * * This file is part of MXD2map. * * This program is free software under the LGPL (>=v2.1) * Read the file LICENCE.txt coming with the software for details * or visit http://www.gnu.org/licenses/ if it does not exist. * * MXD2map has been developed on behalf of the * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg * by Intevation GmbH. * * Authors: * Raimund Renkert <raimund.renkert@intevation.de> * Bjoern Schilberg <bjoern.schilberg@intevation.de> * Stephan Holl <stephan.holl@intevation.de> */ 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.IFeatureRenderer; import com.esri.arcgis.carto.WMSMapLayer; import com.esri.arcgis.carto.WMSGroupLayer; import com.esri.arcgis.carto.WMSLayer; import com.esri.arcgis.gisclient.IWMSServiceDescription; import com.esri.arcgis.geometry.Envelope; import org.w3c.dom.Element; import de.intevation.mxd.utils.MapToXMLUtils; /** * Reads Layer information. * * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> */ public class WMSGroupLayerReader { /** * The logger. */ private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); /** * Privte member. */ private WMSGroupLayer layer; private MapToXMLUtils util; private int invalidLayerCount; /** * Constructor with layer. * * @param layer The ArcGIS layer object. */ public WMSGroupLayerReader(ILayer layer) throws Exception { if(layer instanceof WMSGroupLayer) { this.layer = (WMSGroupLayer)layer; invalidLayerCount = 0; } else { throw new Exception("Not an instance of WMSGroupLayer: " + 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(String group) throws IOException{ logger.debug("read()"); Element layerElement = null; for(int i = 0; i < layer.getCount();i++) { try { ILayer lay = layer.getLayer(i); logger.debug("Reading sublayer " + i + " Name: " + lay.getName()); if(lay instanceof WMSMapLayer) { WMSMapLayerReader lr = new WMSMapLayerReader (lay); lr.setUtil(this.util); layerElement = lr.read("/" + layer.getName()); } else if(lay instanceof WMSGroupLayer) { WMSGroupLayerReader lr = new WMSGroupLayerReader (lay); lr.setUtil(this.util); layerElement = lr.read("/" + layer.getName()); } else if(lay instanceof WMSLayer) { WMSLayerReader lr = new WMSLayerReader (lay); lr.setUtil(this.util); layerElement = lr.read(); } else { logger.error("Sublayer not handled: " + lay.getClass().toString()); } if (layerElement != null) { layerElement.setAttribute("group", group + "/" + layer.getName()); } } catch(Exception e) { logger.debug(e); logger.error("Error reading sublayers. Stop reading: " + layer.getName()); } } return layerElement; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :