comparison 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
comparison
equal deleted inserted replaced
300:215ae6199b95 301:2cb2d8eb56ed
1 /*
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de>
3 *
4 * This file is part of MXD2map.
5 *
6 * This program is free software under the LGPL (>=v2.1)
7 * Read the file LICENCE.txt coming with the software for details
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
9 *
10 * MXD2map has been developed on behalf of the
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
12 * by Intevation GmbH.
13 *
14 * Authors:
15 * Raimund Renkert <raimund.renkert@intevation.de>
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
17 * Stephan Holl <stephan.holl@intevation.de>
18 */
19
20 package de.intevation.mxd.reader;
21
22 import java.io.IOException;
23
24 import org.apache.log4j.Logger;
25
26 import com.esri.arcgis.carto.ILayer;
27 import com.esri.arcgis.carto.IFeatureRenderer;
28 import com.esri.arcgis.carto.WMSMapLayer;
29 import com.esri.arcgis.carto.WMSGroupLayer;
30 import com.esri.arcgis.carto.WMSLayer;
31 import com.esri.arcgis.gisclient.IWMSServiceDescription;
32 import com.esri.arcgis.geometry.Envelope;
33
34 import org.w3c.dom.Element;
35
36 import de.intevation.mxd.utils.MapToXMLUtils;
37
38
39 /**
40 * Reads Layer information.
41 *
42 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a>
43 */
44 public class WMSGroupLayerReader {
45
46 /**
47 * The logger.
48 */
49 private static final Logger logger =
50 Logger.getLogger(FeatureLayerReader.class);
51
52 /**
53 * Privte member.
54 */
55 private WMSGroupLayer layer;
56 private MapToXMLUtils util;
57 private int invalidLayerCount;
58
59 /**
60 * Constructor with layer.
61 *
62 * @param layer The ArcGIS layer object.
63 */
64 public WMSGroupLayerReader(ILayer layer)
65 throws Exception {
66 if(layer instanceof WMSGroupLayer) {
67 this.layer = (WMSGroupLayer)layer;
68 invalidLayerCount = 0;
69 }
70 else {
71 throw new Exception("Not an instance of WMSGroupLayer: " +
72 layer.getClass().toString());
73 }
74 }
75
76 /**
77 * Setter for XML document helper.
78 *
79 * @param util The helper for storing map information.
80 */
81 public void setUtil(MapToXMLUtils util) {
82 this.util = util;
83 }
84
85 /**
86 * Reads the Layer content.
87 *
88 * @return The layer XML element.
89 */
90 public Element read(String group)
91 throws IOException{
92 logger.debug("read()");
93 Element layerElement = null;
94 for(int i = 0; i < layer.getCount();i++) {
95 try {
96 ILayer lay = layer.getLayer(i);
97 logger.debug("Reading sublayer " + i + " Name: " + lay.getName());
98 if(lay instanceof WMSMapLayer) {
99 WMSMapLayerReader lr = new WMSMapLayerReader (lay);
100 lr.setUtil(this.util);
101 layerElement = lr.read("/" + layer.getName());
102 } else if(lay instanceof WMSGroupLayer) {
103 WMSGroupLayerReader lr = new WMSGroupLayerReader (lay);
104 lr.setUtil(this.util);
105 layerElement = lr.read("/" + layer.getName());
106 } else if(lay instanceof WMSLayer) {
107 WMSLayerReader lr = new WMSLayerReader (lay);
108 lr.setUtil(this.util);
109 layerElement = lr.read();
110 } else {
111 logger.error("Sublayer not handled: " + lay.getClass().toString());
112 }
113 if (layerElement != null) {
114 layerElement.setAttribute("group", group + "/" + layer.getName());
115 }
116 }
117 catch(Exception e) {
118 logger.debug(e);
119 logger.error("Error reading sublayers. Stop reading: " + layer.getName());
120 }
121 }
122 return layerElement;
123 }
124 }
125 // 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)