diff src/java/de/intevation/mxd/reader/WMSGroupLayerReader.java @ 301:2cb2d8eb56ed

Add WMS Support in the Reader classes and add new Reader classes for WMS Layers
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 05 Sep 2012 16:19:18 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/intevation/mxd/reader/WMSGroupLayerReader.java	Wed Sep 05 16:19:18 2012 +0200
@@ -0,0 +1,125 @@
+/*
+ * 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 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)