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