Revision 1034 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java

View differences:

FLyrWMS.java
1 1
package com.iver.cit.gvsig.fmap.layers;
2 2

  
3
import java.awt.Graphics2D;
4
import java.awt.Point;
5
import java.awt.geom.Rectangle2D;
6
import java.awt.image.BufferedImage;
7
import java.io.ByteArrayInputStream;
8
import java.io.IOException;
9
import java.net.MalformedURLException;
10
import java.net.URL;
11

  
12
import javax.imageio.ImageIO;
13

  
14
import org.exolab.castor.xml.ValidationException;
15

  
16 3
import com.iver.cit.gvsig.fmap.DriverException;
17 4
import com.iver.cit.gvsig.fmap.ViewPort;
5
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
18 6
import com.iver.cit.gvsig.fmap.drivers.WMSException;
19 7
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint;
20 8
import com.iver.cit.gvsig.fmap.operations.Cancellable;
9

  
21 10
import com.iver.utiles.StringUtilities;
22 11
import com.iver.utiles.XMLEntity;
12

  
23 13
import com.iver.wmsclient.FeatureInfoQuery;
24 14
import com.iver.wmsclient.MapQuery;
25 15
import com.iver.wmsclient.UnsupportedVersionException;
26 16
import com.iver.wmsclient.WMSClient;
27 17
import com.iver.wmsclient.WMSClientFactory;
28 18

  
19
import org.exolab.castor.xml.ValidationException;
29 20

  
21
import java.awt.Graphics2D;
22
import java.awt.Point;
23
import java.awt.geom.Rectangle2D;
24
import java.awt.image.BufferedImage;
25

  
26
import java.io.ByteArrayInputStream;
27
import java.io.IOException;
28

  
29
import java.net.MalformedURLException;
30
import java.net.URL;
31

  
32
import javax.imageio.ImageIO;
33

  
34

  
30 35
/**
31
 * DOCUMENT ME!
36
 * Capa WMS.
32 37
 *
33 38
 * @author Fernando Gonz?lez Cort?s
34 39
 */
......
43 48
	private Rectangle2D fullExtent;
44 49

  
45 50
	/**
46
	 * DOCUMENT ME!
51
	 * Slecciona el formato del WMS.
47 52
	 *
48
	 * @return DOCUMENT ME!
53
	 * @return formato seleccionado.
49 54
	 *
50 55
	 * @throws WMSException
51 56
	 * @throws IllegalStateException
......
84 89
		throw new WMSException("No format supported");
85 90
	}
86 91

  
92
	/**
93
	 * Devuelve el XMLEntity con la informaci?n necesaria para reproducir la
94
	 * capa.
95
	 *
96
	 * @return XMLEntity.
97
	 */
87 98
	public XMLEntity getXMLEntity() {
88 99
		XMLEntity xml = super.getXMLEntity();
89 100

  
......
96 107

  
97 108
		return xml;
98 109
	}
99
	public void setXMLEntity(XMLEntity xml) throws XMLException,
100
			DriverException {
110

  
111
	/**
112
	 * A partir del XMLEntity reproduce la capa.
113
	 *
114
	 * @param xml XMLEntity
115
	 *
116
	 * @throws XMLException
117
	 * @throws DriverException
118
	 * @throws DriverIOException
119
	 */
120
	public void setXMLEntity(XMLEntity xml)
121
		throws XMLException, DriverException, DriverIOException {
101 122
		super.setXMLEntity(xml);
102
		fullExtent = StringUtilities.string2Rect(xml.getStringProperty("fullExtent"));
123
		fullExtent = StringUtilities.string2Rect(xml.getStringProperty(
124
					"fullExtent"));
125

  
103 126
		try {
104 127
			host = new URL(xml.getStringProperty("host"));
105 128
		} catch (MalformedURLException e) {
106 129
			throw new XMLException(e);
107 130
		}
108
		
131

  
109 132
		infoLayerQuery = xml.getStringProperty("infoLayerQuery");
110 133
		layerQuery = xml.getStringProperty("layerQuery");
111 134
		m_Format = xml.getStringProperty("format");
112 135
		m_SRS = xml.getStringProperty("srs");
113 136
	}
114
	/*
115
	 * DOCUMENT ME!
116
	 *
117
	 * @return
118
	 *
119
	public String getFormat() {
120
		return m_Format;
121
	}
122 137

  
123
	/*
124
	 * DOCUMENT ME!
125
	 *
126
	 * @return
127
	 *
128
	public String getSRS() {
129
		return m_SRS;
130
	}
131

  
132
	/*
133
	 * DOCUMENT ME!
134
	 *
135
	 * @param string
136
	 *
137
	public void setFormat(String string) {
138
		m_Format = string;
139
	}
140

  
141
	/*
142
	 * DOCUMENT ME!
143
	 *
144
	 * @param string
145
	 *
146
	public void setQuery(String string) {
147
		layerQuery = string;
148
	}
149

  
150
	/*
151
	 * DOCUMENT ME!
152
	 *
153
	 * @param string
154
	 *
155
	public void setSRS(String string) {
156
		m_SRS = string;
157
	}
158

  
159
	/*
160
	 * @see com.iver.cit.gvsig.fmap.FLyrDefault#isEditable()
161
	 *
162
	public boolean isEditable() {
163
		return false;
164
	}
165

  
166
	/*
167
	 * DOCUMENT ME!
168
	 *
169
	 * @return
170
	 *
171
	public URL getHost() {
172
		return host;
173
	}
174

  
175
	/*
176
	 * DOCUMENT ME!
177
	 *
178
	 * @param url
179
	 *
180
	public void setHost(URL url) {
181
		host = url;
182
	}
183

  
184
	/*
185
	   public static FLyrWMS createFLyrWMS(XMLEntity entity) throws Exception{
186
	           String srs = entity.getStringProperty("srs");
187
	           String format = entity.getStringProperty("format");
188
	           String layerQuery = entity.getStringProperty("layerQuery");
189
	           String infoLayerQuery = entity.getStringProperty("infoLayerQuery");
190
	           String host = entity.getStringProperty("host");
191
	           Rectangle2D.Double r = (Rectangle2D.Double) StringUtilities.string2Rect(entity.getStringProperty("rect"));
192
	           return new FLyrWMS(new URL(host), r, format, layerQuery, infoLayerQuery, srs);
193
	   }
194
	
195
	   public XMLEntity getXMLEntity(){
196
	           XMLEntity xml = new XMLEntity();
197
	           xml.putProperty("srs", m_SRS);
198
	           xml.putProperty("format", m_Format);
199
	           xml.putProperty("layerQuery", layerQuery);
200
	           xml.putProperty("infoLayerQuery", infoLayerQuery);
201
	           xml.putProperty("host", host.toExternalForm());
202
	           xml.putProperty("bbox", StringUtilities.rect2String(this.getLayerExtent()));
203
	
204
	           return xml;
205
	   }
206
	 */
207

  
208
	/*
209
	 * DOCUMENT ME!
210
	 *
211
	 * @return
212
	 *
213
	public String getInfoLayerQuery() {
214
		return infoLayerQuery;
215
	}
216

  
217
	/*
218
	 * DOCUMENT ME!
219
	 *
220
	 * @return
221
	 *
222
	public String getLayerQuery() {
223
		return layerQuery;
224
	}
225

  
226
	/*
227
	 * DOCUMENT ME!
228
	 *
229
	 * @param string
230
	 *
231
	public void setInfoLayerQuery(String string) {
232
		infoLayerQuery = string;
233
	}
234

  
235
	/*
236
	 * DOCUMENT ME!
237
	 *
238
	 * @param string
239
	 *
240
	public void setLayerQuery(String string) {
241
		layerQuery = string;
242
	}
243
*/
244 138
	/**
245 139
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint)
246 140
	 */
......
263 157
			 * TODO Las traducciones en este m?todo han de ser
264 158
			 * las mismas que en el m?todo de dibujado
265 159
			 */
266
			
267 160
			throw new DriverException("No se reconoce el formato de la respuesta",
268
					e);
161
				e);
269 162
		} catch (UnsupportedVersionException e) {
270 163
			throw new DriverException("Conflicto de versiones", e);
271 164
		} catch (IOException e) {
......
336 229
		throws DriverException {
337 230
		draw(null, g, viewPort, cancel);
338 231
	}
339
	
232

  
340 233
	/**
341
	 * DOCUMENT ME!
234
	 * Devuelve el WMSClient.
342 235
	 *
343
	 * @return
236
	 * @return WMSClient
344 237
	 *
345
	 * @throws IllegalStateException DOCUMENT ME!
346
	 * @throws ValidationException DOCUMENT ME!
347
	 * @throws UnsupportedVersionException DOCUMENT ME!
348
	 * @throws IOException DOCUMENT ME!
238
	 * @throws IllegalStateException
239
	 * @throws ValidationException
240
	 * @throws UnsupportedVersionException
241
	 * @throws IOException
349 242
	 */
350 243
	private WMSClient getWmsClient()
351 244
		throws IllegalStateException, ValidationException, 
......
357 250
		return wmsClient;
358 251
	}
359 252

  
253
	/**
254
	 * Devuelve el URL.
255
	 *
256
	 * @return URL.
257
	 */
360 258
	public URL getHost() {
361 259
		return host;
362 260
	}
261

  
262
	/**
263
	 * Inserta el URL.
264
	 *
265
	 * @param host URL.
266
	 */
363 267
	public void setHost(URL host) {
364 268
		this.host = host;
365 269
	}
270

  
271
	/**
272
	 * Devuelve la informaci?n de la consulta.
273
	 *
274
	 * @return String.
275
	 */
366 276
	public String getInfoLayerQuery() {
367 277
		return infoLayerQuery;
368 278
	}
279

  
280
	/**
281
	 * Inserta la informaci?n de la consulta.
282
	 *
283
	 * @param infoLayerQuery String.
284
	 */
369 285
	public void setInfoLayerQuery(String infoLayerQuery) {
370 286
		this.infoLayerQuery = infoLayerQuery;
371 287
	}
288

  
289
	/**
290
	 * Devuelve la consulta.
291
	 *
292
	 * @return String.
293
	 */
372 294
	public String getLayerQuery() {
373 295
		return layerQuery;
374 296
	}
297

  
298
	/**
299
	 * Inserta la consulta.
300
	 *
301
	 * @param layerQuery consulta.
302
	 */
375 303
	public void setLayerQuery(String layerQuery) {
376 304
		this.layerQuery = layerQuery;
377 305
	}
306

  
307
	/**
308
	 * Devuelve el formato.
309
	 *
310
	 * @return Formato.
311
	 */
378 312
	public String getFormat() {
379 313
		return m_Format;
380 314
	}
315

  
316
	/**
317
	 * Inserta el formato.
318
	 *
319
	 * @param format Formato.
320
	 */
381 321
	public void setFormat(String format) {
382 322
		m_Format = format;
383 323
	}
324

  
325
	/**
326
	 * Devuelve el SRS.
327
	 *
328
	 * @return SRS.
329
	 */
384 330
	public String getSRS() {
385 331
		return m_SRS;
386 332
	}
333

  
334
	/**
335
	 * Inserta el SRS.
336
	 *
337
	 * @param m_srs SRS.
338
	 */
387 339
	public void setSRS(String m_srs) {
388 340
		m_SRS = m_srs;
389 341
	}
342

  
343
	/**
344
	 * Inserta la extensi?n total de la capa.
345
	 *
346
	 * @param fullExtent Rect?ngulo.
347
	 */
390 348
	public void setFullExtent(Rectangle2D fullExtent) {
391 349
		this.fullExtent = fullExtent;
392 350
	}

Also available in: Unified diff