comparison src/java/de/intevation/mxd/reader/WMSMapLayerReader.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 WMSMapLayerReader {
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 WMSMapLayer 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 WMSMapLayerReader(ILayer layer)
65 throws Exception {
66 if(layer instanceof WMSMapLayer) {
67 this.layer = (WMSMapLayer)layer;
68 invalidLayerCount = 0;
69 }
70 else {
71 throw new Exception("Not an instance of WMSMapLayer: " +
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("Stepping down into sublayer " + i + " Name: " + lay.getName());
98 logger.debug("Class is: " + lay.getClass().toString());
99 if(lay instanceof WMSMapLayer) {
100 WMSMapLayerReader lr = new WMSMapLayerReader (lay);
101 lr.setUtil(this.util);
102 layerElement = lr.read("/" + layer.getName());
103 } else if(lay instanceof WMSGroupLayer) {
104 WMSGroupLayerReader lr = new WMSGroupLayerReader (lay);
105 lr.setUtil(this.util);
106 layerElement = lr.read("/" + layer.getName());
107 } else if(lay instanceof WMSLayer) {
108 WMSLayerReader lr = new WMSLayerReader (lay);
109 lr.setUtil(this.util);
110 layerElement = lr.read();
111 } else {
112 logger.error("Sublayer not handled: " + lay.getClass().toString());
113 }
114 if (layerElement != null) {
115 layerElement.setAttribute("group", group + "/" + layer.getName());
116 }
117 }
118 catch(Exception e) {
119 logger.debug(e);
120 logger.error("Error reading sublayers. Stop reading: " + layer.getName());
121 }
122 }
123 return layerElement;
124 }
125 }
126 // 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)