Mercurial > mxd2map
view src/java/de/intevation/mxd/reader/WMSMapLayerReader.java @ 331:10939bda0aaa
* contrib/installer/example/example/epsg/epsg:
Add Gauss Kruger zone 2, Germany Zone 2, Germany Zone 3
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 22 Oct 2012 17:38:01 +0200 |
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 WMSMapLayerReader { /** * The logger. */ private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); /** * Privte member. */ private WMSMapLayer layer; private MapToXMLUtils util; private int invalidLayerCount; /** * Constructor with layer. * * @param layer The ArcGIS layer object. */ public WMSMapLayerReader(ILayer layer) throws Exception { if(layer instanceof WMSMapLayer) { this.layer = (WMSMapLayer)layer; invalidLayerCount = 0; } else { throw new Exception("Not an instance of WMSMapLayer: " + 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("Stepping down into sublayer " + i + " Name: " + lay.getName()); logger.debug("Class is: " + lay.getClass().toString()); 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 :