annotate src/java/de/intevation/mxd/reader/WMSLayerReader.java @ 340:dbfcb0b69a63

* contrib/installer/example/example/template.map: Switch to latin1 encoding * contrib/installer/example/example/mapfile_header.include: Remove shapepath, data is now referenced relative to the mapfile
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 09 Nov 2012 16:54:16 +0100
parents 2e445968851f
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.gisclient.IWMSLayerDescription;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 import com.esri.arcgis.geometry.Envelope;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 import org.w3c.dom.Element;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 import de.intevation.mxd.utils.MapToXMLUtils;
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 /**
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 * Reads Layer information.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 *
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 * @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
44 */
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 public class WMSLayerReader {
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 /**
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 * The logger.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 */
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 private static final Logger logger =
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 Logger.getLogger(FeatureLayerReader.class);
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 /**
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 * Privte member.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 */
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 private WMSLayer layer;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 private MapToXMLUtils util;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 private int invalidLayerCount;
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 /**
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 * Constructor with layer.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 *
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63 * @param layer The ArcGIS layer object.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 */
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 public WMSLayerReader(ILayer layer)
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
66 throws Exception {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 if(layer instanceof WMSLayer) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 this.layer = (WMSLayer)layer;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69 invalidLayerCount = 0;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 else {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 throw new Exception("Not an instance of WMSLayer: " +
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 layer.getClass().toString());
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 /**
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 * Setter for XML document helper.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79 *
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
80 * @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
81 */
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82 public void setUtil(MapToXMLUtils util) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
83 this.util = util;
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 /**
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
87 * Reads the Layer content.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
88 *
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
89 * @return The layer XML element.
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
90 */
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
91 public Element read()
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
92 throws IOException{
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
93 logger.debug("read()");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
94 Element layerElement = null;
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 layerElement = util.addLayer();
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
97 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
98 catch(Exception e) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
99 logger.error("Failed to create DOM-Element for Layer.");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
100 return null;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
101 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
102 try {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
103 layerElement.setAttribute("name", layer.getName());
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
104 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
105 catch(IOException ioe) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
106 logger.warn(
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
107 "Could not read layer name." +
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
108 " Stopped reading layer.");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
109 throw new IOException("Error reading layer name.");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
110 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
111
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
112 try {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
113 layerElement.setAttribute("min_scale",
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
114 String.valueOf(layer.getMinimumScale()));
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 catch(IOException ioe) {
316
5e3a40a84539 Some minor cleanups
Andre Heinecke <aheinecke@intevation.de>
parents: 301
diff changeset
117 logger.debug("Could not read minimum scale.");
5e3a40a84539 Some minor cleanups
Andre Heinecke <aheinecke@intevation.de>
parents: 301
diff changeset
118 layerElement.setAttribute("min_scale", "0");
301
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
119 }
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 try {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
122 layerElement.setAttribute("max_scale",
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
123 String.valueOf(layer.getMaximumScale()));
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 catch(IOException ioe) {
316
5e3a40a84539 Some minor cleanups
Andre Heinecke <aheinecke@intevation.de>
parents: 301
diff changeset
126 logger.debug(
301
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
127 "Could not read maximum scale.");
316
5e3a40a84539 Some minor cleanups
Andre Heinecke <aheinecke@intevation.de>
parents: 301
diff changeset
128 layerElement.setAttribute("max_scale", "0");
301
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
129 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
130
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
131 try {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
132 if(layer.isVisible()) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
133 layerElement.setAttribute("status", "on");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
134 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
135 else {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
136 layerElement.setAttribute("status", "off");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
137 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
138 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
139 catch(IOException ioe) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
140 logger.warn(
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
141 "Could not read layer status." +
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
142 " Setting layer status to \"on\".");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
143 layerElement.setAttribute("status", "on");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
144 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
145
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
146 layerElement.setAttribute("connection_type", "WMS");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
147
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
148 try{
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
149 // Set the WMS Connection parameters
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
150 IWMSServiceDescription wmsconn = layer.getWMSServiceDescription();
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
151
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
152 String connectionURL = wmsconn.getBaseURL("GetMap", "Get");
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
153 if (!connectionURL.endsWith("?")) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
154 connectionURL += "?";
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
155 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
156 layerElement.setAttribute("connection", connectionURL);
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
157 logger.debug(connectionURL);
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
158 layerElement.setAttribute("imageType", wmsconn.getImageFormat(0));
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
159 logger.debug(wmsconn.getImageFormat(0));
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
160 if (wmsconn.getSRSCount() > 0) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
161 layerElement.setAttribute("projection", wmsconn.getSRS(0));
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
162 logger.debug(wmsconn.getSRS(0));
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
163 }
334
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
164 String wms_version = wmsconn.getWMSVersion();
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
165 if (wms_version != "1.0.0" && wms_version != "1.0.7" &&
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
166 wms_version != "1.1.0" && wms_version != "1.1.1") {
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
167 logger.warn("WMS Version " + wms_version + " not supported by" +
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
168 "Mapserver. Falling back to Version 1.1.1");
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
169 wms_version = "1.1.1";
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
170 }
2e445968851f * src/java/de/intevation/mxd/reader/WMSLayerReader.java:
Andre Heinecke <aheinecke@intevation.de>
parents: 316
diff changeset
171 layerElement.setAttribute("wms_server_version", wms_version);
301
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
172 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
173 catch(Exception e) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
174 logger.debug(e);
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
175 logger.error("Error Setting Connection parameters. " + layer.getName());
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
176 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
177
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
178 try{
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
179 // Set the WMS Layer parameters
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
180 IWMSLayerDescription wmslayer = layer.getWMSLayerDescription();
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
181 layerElement.setAttribute("wms_name", wmslayer.getName());
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
182 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
183 catch(Exception e) {
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
184 logger.debug(e);
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
185 logger.error("Error Setting Layer parameters. " + layer.getName());
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
186 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
187 return layerElement;
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
188 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
189 }
2cb2d8eb56ed Add WMS Support in the Reader classes and
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
190 // 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)