svn-gvsig-desktop / tags / v1_0_2_Build_899 / extensions / extWMS / src / com / iver / cit / gvsig / fmap / layers / FLyrWMS.java @ 10517
History | View | Annotate | Download (55.5 KB)
1 | 4503 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 3746 | jaume | *
|
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 4503 | jaume | * Av. Blasco Ib??ez, 50
|
24 | 3746 | jaume | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package com.iver.cit.gvsig.fmap.layers; |
||
42 | |||
43 | import java.awt.Component; |
||
44 | 3841 | nacho | import java.awt.Dimension; |
45 | 3746 | jaume | import java.awt.Graphics2D; |
46 | 8765 | jjdelcerro | import java.awt.Image; |
47 | 3746 | jaume | import java.awt.Point; |
48 | 3840 | nacho | import java.awt.Rectangle; |
49 | 3746 | jaume | import java.awt.geom.AffineTransform; |
50 | import java.awt.geom.NoninvertibleTransformException; |
||
51 | import java.awt.geom.Point2D; |
||
52 | import java.awt.geom.Rectangle2D; |
||
53 | import java.awt.image.BufferedImage; |
||
54 | 4378 | nacho | import java.awt.image.DataBuffer; |
55 | 3746 | jaume | import java.io.File; |
56 | import java.io.IOException; |
||
57 | import java.lang.reflect.Constructor; |
||
58 | import java.lang.reflect.InvocationTargetException; |
||
59 | import java.net.MalformedURLException; |
||
60 | import java.net.URL; |
||
61 | import java.util.ArrayList; |
||
62 | import java.util.HashMap; |
||
63 | 3841 | nacho | import java.util.Hashtable; |
64 | 4222 | jaume | import java.util.Iterator; |
65 | 4677 | jorpiell | import java.util.Map; |
66 | 3746 | jaume | import java.util.Vector; |
67 | |||
68 | 8765 | jjdelcerro | import javax.imageio.ImageIO; |
69 | 9013 | caballero | import javax.print.attribute.PrintRequestAttributeSet; |
70 | 5763 | jmvivo | import javax.swing.ImageIcon; |
71 | 3746 | jaume | import javax.swing.JOptionPane; |
72 | |||
73 | 5981 | nacho | import org.cresques.filter.RasterFilterStack; |
74 | import org.cresques.filter.RasterFilterStackManager; |
||
75 | 3746 | jaume | import org.cresques.geo.ViewPortData; |
76 | 5991 | nacho | import org.cresques.io.GdalFile; |
77 | 3746 | jaume | import org.cresques.io.GeoRasterFile; |
78 | 9056 | nacho | import org.cresques.io.data.Grid; |
79 | import org.cresques.io.exceptions.NotSupportedExtensionException; |
||
80 | 3746 | jaume | import org.cresques.px.Extent; |
81 | import org.cresques.px.PxRaster; |
||
82 | import org.exolab.castor.xml.ValidationException; |
||
83 | import org.gvsig.remoteClient.utils.Utilities; |
||
84 | 5409 | jaume | import org.gvsig.remoteClient.wms.ICancellable; |
85 | 3746 | jaume | import org.gvsig.remoteClient.wms.WMSStatus; |
86 | |||
87 | import com.iver.andami.PluginServices; |
||
88 | 4222 | jaume | import com.iver.andami.messages.NotificationManager; |
89 | 8765 | jjdelcerro | import com.iver.cit.gvsig.fmap.ConnectionErrorExceptionType; |
90 | 3746 | jaume | import com.iver.cit.gvsig.fmap.DriverException; |
91 | 8765 | jjdelcerro | import com.iver.cit.gvsig.fmap.UnknownResponseFormatExceptionType; |
92 | import com.iver.cit.gvsig.fmap.UnsuportedProtocolVersionExceptionType; |
||
93 | 3746 | jaume | import com.iver.cit.gvsig.fmap.ViewPort; |
94 | 8765 | jjdelcerro | import com.iver.cit.gvsig.fmap.WMSDriverExceptionType; |
95 | 3746 | jaume | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
96 | import com.iver.cit.gvsig.fmap.drivers.UnsupportedVersionException; |
||
97 | import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
||
98 | 5279 | jmvivo | import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory; |
99 | 5409 | jaume | import com.iver.cit.gvsig.fmap.drivers.wms.WMSException; |
100 | 4730 | jaume | import com.iver.cit.gvsig.fmap.layers.WMSLayerNode.FMapWMSStyle; |
101 | 8765 | jjdelcerro | import com.iver.cit.gvsig.fmap.layers.layerOperations.IHasImageLegend; |
102 | 3746 | jaume | import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
103 | 5055 | ldiaz | import com.iver.cit.gvsig.fmap.layers.layerOperations.StringXMLItem; |
104 | 5203 | ldiaz | import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem; |
105 | 4730 | jaume | import com.iver.cit.gvsig.fmap.rendering.XmlBuilder; |
106 | 5023 | jaume | import com.iver.cit.gvsig.wmc.WebMapContextTags; |
107 | 3746 | jaume | import com.iver.utiles.StringUtilities; |
108 | import com.iver.utiles.XMLEntity; |
||
109 | 5347 | jaume | import com.iver.utiles.swing.threads.Cancellable; |
110 | 3746 | jaume | |
111 | |||
112 | 5203 | ldiaz | |
113 | 3746 | jaume | /**
|
114 | 4222 | jaume | * FMap's WMS Layer class.
|
115 | 3746 | jaume | *
|
116 | 3749 | jaume | * @author Jaume Dominguez Faus
|
117 | 8765 | jjdelcerro | * Nacho Brodin
|
118 | 6050 | jaume | *
|
119 | 3746 | jaume | */
|
120 | 8765 | jjdelcerro | public class FLyrWMS extends FLyrDefault implements InfoByPoint, RasterOperations, IHasImageLegend { |
121 | 4222 | jaume | private boolean isPrinting = false; |
122 | 5534 | nacho | private boolean mustTileDraw = true; |
123 | 4222 | jaume | private boolean mustTilePrint = true; |
124 | 5534 | nacho | private final int maxTileDrawWidth = 1023; |
125 | private final int maxTileDrawHeight = 1023; |
||
126 | private final int maxTilePrintWidth = 1023; |
||
127 | private final int maxTilePrintHeight = 1023; |
||
128 | 6822 | jaume | private final int minTilePrintWidth = 12; |
129 | private final int minTilePrintHeight = 12; |
||
130 | 6050 | jaume | |
131 | 4222 | jaume | public URL host; |
132 | public String m_Format; |
||
133 | 6050 | jaume | |
134 | 4222 | jaume | private String m_SRS; |
135 | private String layerQuery; |
||
136 | private String infoLayerQuery; |
||
137 | private FMapWMSDriver wms;
|
||
138 | private WMSStatus wmsStatus = new WMSStatus(); |
||
139 | private Rectangle2D fullExtent; |
||
140 | private boolean wmsTransparency; |
||
141 | private Vector styles; |
||
142 | private Vector dimensions; |
||
143 | 3746 | jaume | private StatusRasterInterface status = null; |
144 | private int posX = 0, posY = 0; |
||
145 | private double posXWC = 0, posYWC = 0; |
||
146 | private int r = 0, g = 0, b = 0; |
||
147 | private GeoRasterFile rasterFile = null; |
||
148 | private PxRaster raster = null; |
||
149 | private RasterFilterStack filterStack = null; |
||
150 | 3756 | jaume | private boolean firstLoad = false; |
151 | 3746 | jaume | private int transparency = -1; |
152 | private int rband = 0, gband = 1, bband = 2; |
||
153 | private RasterFilterStackManager stackManager = null; |
||
154 | 4222 | jaume | private Hashtable onlineResources = new Hashtable(); |
155 | private Dimension fixedSize; |
||
156 | private boolean queryable = true; |
||
157 | private VisualStatusWMS visualStatus = new VisualStatusWMS(); |
||
158 | 9056 | nacho | private Grid grid = null; |
159 | 6050 | jaume | |
160 | |||
161 | 5409 | jaume | private class MyCancellable implements ICancellable |
162 | { |
||
163 | private Cancellable original;
|
||
164 | public MyCancellable(Cancellable cancelOriginal)
|
||
165 | { |
||
166 | this.original = cancelOriginal;
|
||
167 | } |
||
168 | public boolean isCanceled() { |
||
169 | 8765 | jjdelcerro | if (original == null) return false; |
170 | 5409 | jaume | return original.isCanceled();
|
171 | } |
||
172 | 6050 | jaume | |
173 | 5409 | jaume | } |
174 | 6050 | jaume | |
175 | 4677 | jorpiell | public FLyrWMS(){
|
176 | super();
|
||
177 | } |
||
178 | 6050 | jaume | |
179 | 4677 | jorpiell | public FLyrWMS(Map args) throws DriverIOException{ |
180 | FMapWMSDriver drv = null;
|
||
181 | String host = (String)args.get("host"); |
||
182 | String sLayer = (String)args.get("layer"); |
||
183 | Rectangle2D fullExtent = (Rectangle2D)args.get("FullExtent"); |
||
184 | String sSRS = (String)args.get("SRS"); |
||
185 | String sFormat = (String)args.get("Format"); |
||
186 | String[] sLayers = sLayer.split(","); |
||
187 | 6050 | jaume | |
188 | 4677 | jorpiell | try {
|
189 | this.setHost(new URL(host)); |
||
190 | } catch (MalformedURLException e) { |
||
191 | //e.printStackTrace();
|
||
192 | 6050 | jaume | throw new DriverIOException("Malformed host URL, '" + host + "' (" + e.toString() + ")."); |
193 | 4677 | jorpiell | } |
194 | try {
|
||
195 | 10208 | jorpiell | drv = this.getDriver();
|
196 | 4677 | jorpiell | } catch (Exception e) { |
197 | // e.printStackTrace();
|
||
198 | 6050 | jaume | throw new DriverIOException("Can't get driver to host '" + host + "' (" + e.toString() + ")."); |
199 | 4677 | jorpiell | } |
200 | if( sFormat == null || sSRS == null || fullExtent == null ) { |
||
201 | 5409 | jaume | if (!drv.connect(null)) |
202 | 6050 | jaume | throw new DriverIOException("Can't connect to host '" + host + "'."); |
203 | |||
204 | 4677 | jorpiell | WMSLayerNode wmsNode = drv.getLayer(sLayer); |
205 | 10208 | jorpiell | |
206 | 4677 | jorpiell | if (wmsNode == null){ |
207 | throw new DriverIOException("The server '" + host + "' doesn't has the layer '" + sLayer + "'."); |
||
208 | 6050 | jaume | } |
209 | 4677 | jorpiell | if( sFormat == null ) { |
210 | sFormat = this.getGreatFormat(drv.getFormats());
|
||
211 | } |
||
212 | 10208 | jorpiell | |
213 | //SRS
|
||
214 | Vector allSrs = wmsNode.getAllSrs();
|
||
215 | boolean isSRSSupported = false; |
||
216 | if( sSRS != null ) { |
||
217 | for (int i=0; i<allSrs.size() ; i++){ |
||
218 | if (((String)allSrs.get(i)).compareTo(sSRS) == 0){ |
||
219 | isSRSSupported = true;
|
||
220 | } |
||
221 | } |
||
222 | } |
||
223 | |||
224 | if(!isSRSSupported) {
|
||
225 | 9536 | jcampos | for (int i=0; i<allSrs.size() ; i++){ |
226 | if (((String)wmsNode.getAllSrs().get(i)).compareTo("EPSG:4326") == 0){ |
||
227 | sSRS = (String)wmsNode.getAllSrs().get(i);
|
||
228 | } |
||
229 | } |
||
230 | if (sSRS==null){ |
||
231 | sSRS = (String)wmsNode.getAllSrs().get(0); |
||
232 | } |
||
233 | 4677 | jorpiell | } |
234 | if( fullExtent == null ) { |
||
235 | 10208 | jorpiell | fullExtent = drv.getLayersExtent(sLayers,sSRS); |
236 | 4677 | jorpiell | } |
237 | } |
||
238 | 6050 | jaume | |
239 | |||
240 | 4677 | jorpiell | this.setFullExtent(fullExtent);
|
241 | this.setFormat(sFormat);
|
||
242 | this.setLayerQuery(sLayer);
|
||
243 | this.setInfoLayerQuery(""); |
||
244 | this.setSRS(sSRS);
|
||
245 | this.setName(sLayer);
|
||
246 | 10208 | jorpiell | this.setOnlineResources(drv.getOnlineResources());
|
247 | load(); |
||
248 | 4677 | jorpiell | } |
249 | 6050 | jaume | |
250 | 4222 | jaume | /**
|
251 | 6050 | jaume | * It choose the best format to load different maps if the server
|
252 | * supports it. This format could be png, because it supports
|
||
253 | 4677 | jorpiell | * transparency.
|
254 | * @param formats
|
||
255 | * Arraywith all the formats supported by the server
|
||
256 | * @return
|
||
257 | 6050 | jaume | */
|
258 | 4677 | jorpiell | private String getGreatFormat(Vector formats){ |
259 | for (int i=0 ; i<formats.size() ; i++){ |
||
260 | String format = (String) formats.get(i); |
||
261 | if (format.equals("image/jpg")){ |
||
262 | return format;
|
||
263 | } |
||
264 | if (format.equals("image/jpeg")){ |
||
265 | return format;
|
||
266 | } |
||
267 | } |
||
268 | 6050 | jaume | |
269 | 4677 | jorpiell | return (String)formats.get(0); |
270 | } |
||
271 | 6050 | jaume | |
272 | 4677 | jorpiell | /**
|
273 | 9056 | nacho | * Clase que contiene los datos de visualizaci?n de WMS. Tiene datos que representan al
|
274 | * raster en la vista. Este raster puede estar compuesto por tiles por lo que valores
|
||
275 | * como el ancho total o el m?nimo o m?ximo deben ser calculados a partir de todos los
|
||
276 | * tiles visualizados.
|
||
277 | 4222 | jaume | * @author Nacho Brodin (brodin_ign@gva.es)
|
278 | */
|
||
279 | private class VisualStatusWMS{ |
||
280 | /**
|
||
281 | 6050 | jaume | * Ancho y alto de la imagen o del conjunto de tiles si los tiene. Coincide con
|
282 | 4222 | jaume | * el ancho y alto del viewPort
|
283 | */
|
||
284 | private int width = 0, height = 0; |
||
285 | private double minX = 0D, minY = 0D, maxX = 0D, maxY = 0D; |
||
286 | 4378 | nacho | private int bandCount = 0; |
287 | private int dataType = DataBuffer.TYPE_UNDEFINED; |
||
288 | 9056 | nacho | |
289 | /**
|
||
290 | * Ancho y alto total del raster que ser? la suma de todos los tiles.
|
||
291 | */
|
||
292 | private int rasterWidth = 0, rasterHeight = 0; |
||
293 | private double rasterMinX = Double.MAX_VALUE, rasterMinY = Double.MAX_VALUE; |
||
294 | private double rasterMaxX = 0, rasterMaxY = 0; |
||
295 | /**
|
||
296 | * Lista de nombre de fichero que componen toda la visualizaci?n.
|
||
297 | */
|
||
298 | private String[] fileNames = null; |
||
299 | 4222 | jaume | } |
300 | 3746 | jaume | |
301 | 6050 | jaume | |
302 | 3746 | jaume | /**
|
303 | * Devuelve el XMLEntity con la informaci?n necesaria para reproducir la
|
||
304 | * capa.
|
||
305 | *
|
||
306 | * @return XMLEntity.
|
||
307 | * @throws XMLException
|
||
308 | */
|
||
309 | public XMLEntity getXMLEntity() throws XMLException { |
||
310 | XMLEntity xml = super.getXMLEntity();
|
||
311 | |||
312 | 4222 | jaume | // Full extent
|
313 | 3746 | jaume | xml.putProperty("fullExtent", StringUtilities.rect2String(fullExtent));
|
314 | 6050 | jaume | |
315 | 4222 | jaume | // Host
|
316 | 3746 | jaume | xml.putProperty("host", host.toExternalForm());
|
317 | 6050 | jaume | |
318 | 4222 | jaume | // Part of the query that is not the host, or the
|
319 | // layer names, or other not listed bellow
|
||
320 | 3746 | jaume | xml.putProperty("infoLayerQuery", infoLayerQuery);
|
321 | 6050 | jaume | |
322 | 4222 | jaume | // Part of the query containing the layer names
|
323 | 3746 | jaume | xml.putProperty("layerQuery", layerQuery);
|
324 | 6050 | jaume | |
325 | 4222 | jaume | // Format
|
326 | 3746 | jaume | xml.putProperty("format", m_Format);
|
327 | 6050 | jaume | |
328 | 4222 | jaume | // SRS
|
329 | 3746 | jaume | xml.putProperty("srs", m_SRS);
|
330 | if (status!=null) |
||
331 | status.getXMLEntity(xml, true, this); |
||
332 | else{
|
||
333 | status = new StatusLayerRaster();
|
||
334 | status.getXMLEntity(xml, true, this); |
||
335 | } |
||
336 | 6050 | jaume | |
337 | 4222 | jaume | // Transparency
|
338 | 3746 | jaume | xml.putProperty("wms_transparency", wmsTransparency);
|
339 | 6050 | jaume | |
340 | 4222 | jaume | // Styles
|
341 | 3746 | jaume | if (styles!=null){ |
342 | String stylePr = ""; |
||
343 | for (int i = 0; i < styles.size(); i++) { |
||
344 | stylePr += (String) styles.get(i);
|
||
345 | if (i<styles.size()-1) |
||
346 | stylePr += ",";
|
||
347 | } |
||
348 | 4222 | jaume | if (stylePr.endsWith(",")) |
349 | stylePr += " ";
|
||
350 | 3746 | jaume | xml.putProperty("styles", stylePr);
|
351 | } |
||
352 | 6050 | jaume | |
353 | // Dimensions
|
||
354 | 3746 | jaume | if (dimensions!=null){ |
355 | String dim = ""; |
||
356 | for (int i = 0; i < dimensions.size(); i++) { |
||
357 | dim += (String) dimensions.get(i);
|
||
358 | if (i<dimensions.size()-1) |
||
359 | dim += ",";
|
||
360 | } |
||
361 | 4222 | jaume | if (dim.endsWith(",")) |
362 | dim += " ";
|
||
363 | 3746 | jaume | xml.putProperty("dimensions", dim);
|
364 | } |
||
365 | 6050 | jaume | |
366 | 4222 | jaume | // OnlineResources
|
367 | Iterator it = onlineResources.keySet().iterator();
|
||
368 | String strOnlines = ""; |
||
369 | while (it.hasNext()) {
|
||
370 | String key = (String) it.next(); |
||
371 | String value = (String) onlineResources.get(key); |
||
372 | strOnlines = key+"~##SEP2##~"+value;
|
||
373 | if (it.hasNext())
|
||
374 | strOnlines += "~##SEP1##~";
|
||
375 | } |
||
376 | xml.putProperty("onlineResources", strOnlines);
|
||
377 | 6050 | jaume | |
378 | 4222 | jaume | // Queryable
|
379 | xml.putProperty("queryable", queryable);
|
||
380 | 6050 | jaume | |
381 | 4222 | jaume | // fixedSize
|
382 | if (isSizeFixed()) {
|
||
383 | xml.putProperty("fixedSize", true); |
||
384 | xml.putProperty("fixedWidth", fixedSize.width);
|
||
385 | xml.putProperty("fixedHeight", fixedSize.height);
|
||
386 | } |
||
387 | 3746 | jaume | return xml;
|
388 | } |
||
389 | |||
390 | /**
|
||
391 | * A partir del XMLEntity reproduce la capa.
|
||
392 | *
|
||
393 | * @param xml XMLEntity
|
||
394 | *
|
||
395 | * @throws XMLException
|
||
396 | * @throws DriverException
|
||
397 | * @throws DriverIOException
|
||
398 | */
|
||
399 | public void setXMLEntity03(XMLEntity xml) |
||
400 | throws XMLException {
|
||
401 | super.setXMLEntity(xml);
|
||
402 | fullExtent = StringUtilities.string2Rect(xml.getStringProperty( |
||
403 | "fullExtent"));
|
||
404 | |||
405 | try {
|
||
406 | host = new URL(xml.getStringProperty("host")); |
||
407 | } catch (MalformedURLException e) { |
||
408 | throw new XMLException(e); |
||
409 | } |
||
410 | |||
411 | infoLayerQuery = xml.getStringProperty("infoLayerQuery");
|
||
412 | layerQuery = xml.getStringProperty("layerQuery");
|
||
413 | m_Format = xml.getStringProperty("format");
|
||
414 | m_SRS = xml.getStringProperty("srs");
|
||
415 | } |
||
416 | |||
417 | /**
|
||
418 | * A partir del XMLEntity reproduce la capa.
|
||
419 | *
|
||
420 | * @param xml XMLEntity
|
||
421 | *
|
||
422 | * @throws XMLException
|
||
423 | * @throws DriverException
|
||
424 | * @throws DriverIOException
|
||
425 | */
|
||
426 | public void setXMLEntity(XMLEntity xml) |
||
427 | throws XMLException {
|
||
428 | super.setXMLEntity(xml);
|
||
429 | fullExtent = StringUtilities.string2Rect(xml.getStringProperty( |
||
430 | "fullExtent"));
|
||
431 | 6050 | jaume | |
432 | 4222 | jaume | // Host
|
433 | 3746 | jaume | try {
|
434 | host = new URL(xml.getStringProperty("host")); |
||
435 | } catch (MalformedURLException e) { |
||
436 | throw new XMLException(e); |
||
437 | } |
||
438 | |||
439 | 4222 | jaume | // Part of the query that is not the host, or the
|
440 | // layer names, or other not listed bellow
|
||
441 | 3746 | jaume | infoLayerQuery = xml.getStringProperty("infoLayerQuery");
|
442 | 4222 | jaume | |
443 | // Part of the query containing the layer names
|
||
444 | 3746 | jaume | layerQuery = xml.getStringProperty("layerQuery");
|
445 | 6050 | jaume | |
446 | 4222 | jaume | // Format
|
447 | 3746 | jaume | m_Format = xml.getStringProperty("format");
|
448 | 6050 | jaume | |
449 | 4222 | jaume | // SRS
|
450 | 3746 | jaume | m_SRS = xml.getStringProperty("srs");
|
451 | 6050 | jaume | |
452 | 4222 | jaume | String claseStr = StatusLayerRaster.defaultClass;
|
453 | 3746 | jaume | if (xml.contains("raster.class")) { |
454 | claseStr = xml.getStringProperty("raster.class");
|
||
455 | } |
||
456 | 6050 | jaume | |
457 | 4222 | jaume | // Transparency
|
458 | 3746 | jaume | if (xml.contains("wms_transparency")) |
459 | wmsTransparency = xml.getBooleanProperty("wms_transparency");
|
||
460 | 6050 | jaume | |
461 | 4222 | jaume | // Styles
|
462 | 3746 | jaume | if (xml.contains("styles")){ |
463 | styles = new Vector(); |
||
464 | String[] stl = xml.getStringProperty("styles").split(","); |
||
465 | 6050 | jaume | |
466 | 3746 | jaume | for (int i = 0; i < stl.length; i++) { |
467 | 4222 | jaume | if (stl[i].equals(" ")) |
468 | stl[i]="";
|
||
469 | 3746 | jaume | styles.add(stl[i]); |
470 | } |
||
471 | } |
||
472 | 6050 | jaume | |
473 | 4222 | jaume | // Dimensions
|
474 | 3746 | jaume | if (xml.contains("dimensions")){ |
475 | dimensions = new Vector(); |
||
476 | String[] dims = xml.getStringProperty("dimensions").split(","); |
||
477 | for (int i = 0; i < dims.length; i++){ |
||
478 | 4222 | jaume | if (dims[i].equals(" ")) |
479 | dims[i]="";
|
||
480 | 6050 | jaume | |
481 | 3746 | jaume | dimensions.add(dims[i]); |
482 | } |
||
483 | } |
||
484 | 6050 | jaume | |
485 | 4222 | jaume | // OnlineResources
|
486 | if (xml.contains("onlineResources")) { |
||
487 | String[] operations = xml.getStringProperty("onlineResources").split("~##SEP1##~"); |
||
488 | for (int i = 0; i < operations.length; i++) { |
||
489 | String[] resources = operations[i].split("~##SEP2##~"); |
||
490 | if (resources.length==2 && resources[1]!="") |
||
491 | onlineResources.put(resources[0], resources[1]); |
||
492 | } |
||
493 | } |
||
494 | 6050 | jaume | |
495 | 4222 | jaume | // Queryable
|
496 | queryable = true; // let's assume that the layer is queryable by default |
||
497 | if (xml.contains("queryable")) |
||
498 | queryable = xml.getBooleanProperty("queryable");
|
||
499 | 6050 | jaume | |
500 | 4222 | jaume | // fixedSize
|
501 | if (xml.contains("fixedSize")) { |
||
502 | 6050 | jaume | fixedSize = new Dimension(xml.getIntProperty("fixedWidth"), |
503 | 4222 | jaume | xml.getIntProperty("fixedHeight"));
|
504 | } |
||
505 | 6050 | jaume | |
506 | 3746 | jaume | if(status!=null) |
507 | status.setXMLEntity(xml, this);
|
||
508 | else{
|
||
509 | if(claseStr!=null && !claseStr.equals("")){ |
||
510 | try{
|
||
511 | Class clase = Class.forName(claseStr); |
||
512 | Constructor constr = clase.getConstructor(null); |
||
513 | status = (StatusRasterInterface)constr.newInstance(null);
|
||
514 | if(status!=null) |
||
515 | status.setXMLEntity(xml, this);
|
||
516 | }catch(ClassNotFoundException exc){ |
||
517 | exc.printStackTrace(); |
||
518 | }catch(InstantiationException exc){ |
||
519 | exc.printStackTrace(); |
||
520 | }catch(IllegalAccessException exc){ |
||
521 | exc.printStackTrace(); |
||
522 | }catch(NoSuchMethodException exc){ |
||
523 | exc.printStackTrace(); |
||
524 | }catch(InvocationTargetException exc){ |
||
525 | exc.printStackTrace(); |
||
526 | 6050 | jaume | } |
527 | 3746 | jaume | } |
528 | } |
||
529 | firstLoad = true;
|
||
530 | } |
||
531 | |||
532 | /**
|
||
533 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint)
|
||
534 | */
|
||
535 | 8765 | jjdelcerro | public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancellable) throws DriverException { |
536 | 5055 | ldiaz | XMLItem[] item = new XMLItem[1]; |
537 | 6050 | jaume | try {
|
538 | 4222 | jaume | if (queryable)
|
539 | { |
||
540 | //TODO
|
||
541 | // check if there are layers which are not queryable
|
||
542 | 6881 | cesar | ViewPort viewPort = getMapContext().getViewPort(); |
543 | 4222 | jaume | |
544 | Point tiledPoint = new Point((int) p.getX() % maxTilePrintWidth, (int) p.getY() % maxTilePrintHeight); |
||
545 | Rectangle rect = new Rectangle(0, 0, viewPort.getImageWidth() - 1, viewPort.getImageHeight() - 1); |
||
546 | Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, rect);
|
||
547 | tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
|
||
548 | int nCols = tiles.getNumCols();
|
||
549 | |||
550 | int col = (int) p.getX() / maxTilePrintWidth; |
||
551 | int row = (int) p.getY() / maxTilePrintHeight; |
||
552 | int tileIndex = (row*nCols) + col;
|
||
553 | 6050 | jaume | |
554 | 4222 | jaume | ViewPort vp = tiles.getTileViewPort(viewPort, tileIndex); |
555 | 8907 | jaume | wmsStatus.setExtent(vp.getAdjustedExtent()); |
556 | 4222 | jaume | wmsStatus.setHeight(vp.getImageHeight()); |
557 | wmsStatus.setWidth(vp.getImageWidth()); |
||
558 | wmsStatus.setOnlineResource((String) onlineResources.get("GetFeatureInfo")); |
||
559 | 8765 | jjdelcerro | MyCancellable c = new MyCancellable(cancellable);
|
560 | 5055 | ldiaz | item[0] = new StringXMLItem(new String(getDriver() |
561 | 8765 | jjdelcerro | .getFeatureInfo(wmsStatus, (int) tiledPoint.getX(), (int) tiledPoint.getY(), Integer.MAX_VALUE, c)),this); |
562 | 5055 | ldiaz | return item;
|
563 | 4222 | jaume | } |
564 | else
|
||
565 | { |
||
566 | 8765 | jjdelcerro | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),this.getName() + " " + |
567 | PluginServices.getText(this,"layer_not_queryable")); |
||
568 | 5203 | ldiaz | item[0] = new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><info></info>",this); |
569 | 5055 | ldiaz | return item;
|
570 | 8765 | jjdelcerro | //return null;
|
571 | 4222 | jaume | } |
572 | 3746 | jaume | } catch (WMSException e) {
|
573 | 5055 | ldiaz | item[0] = new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><exception>" + |
574 | 5203 | ldiaz | e.getMessage() + "</exception>", this); |
575 | 5055 | ldiaz | return item;
|
576 | 8765 | jjdelcerro | } |
577 | /*azabala
|
||
578 | catch (ValidationException e) {
|
||
579 | 4222 | jaume | throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e);
|
580 | 3746 | jaume | } catch (UnsupportedVersionException e) {
|
581 | 4222 | jaume | throw new DriverException(PluginServices.getText(this, "version_conflict"), e);
|
582 | 3746 | jaume | } catch (IOException e) {
|
583 | 4222 | jaume | throw new DriverException(PluginServices.getText(this, "connect_error"), e);
|
584 | 8765 | jjdelcerro | }
|
585 | */
|
||
586 | catch (ValidationException e) {
|
||
587 | UnknownResponseFormatExceptionType type = |
||
588 | new UnknownResponseFormatExceptionType();
|
||
589 | type.setLayerName(getName()); |
||
590 | try {
|
||
591 | type.setDriverName("WMS Driver");
|
||
592 | } catch (Exception e1) { |
||
593 | e1.printStackTrace(); |
||
594 | } |
||
595 | type.setFormat(m_Format); |
||
596 | type.setHost(host); |
||
597 | type.setProtocol("WMS");
|
||
598 | DriverException exception = new DriverException("unknown_response_format", type); |
||
599 | throw exception;
|
||
600 | |||
601 | } catch (UnsupportedVersionException e) {
|
||
602 | UnsuportedProtocolVersionExceptionType type = |
||
603 | new UnsuportedProtocolVersionExceptionType();
|
||
604 | type.setLayerName(getName()); |
||
605 | try {
|
||
606 | type.setDriverName("WMS Driver");
|
||
607 | } catch (Exception ex){ |
||
608 | } |
||
609 | type.setUrl(host); |
||
610 | throw new DriverException(PluginServices.getText(this, "version_conflict"), e, type); |
||
611 | |||
612 | } catch (IOException e) { |
||
613 | ConnectionErrorExceptionType type = new ConnectionErrorExceptionType();
|
||
614 | type.setLayerName(getName()); |
||
615 | try {
|
||
616 | type.setDriverName("WMS Driver");
|
||
617 | } catch (Exception e1) { |
||
618 | } |
||
619 | type.setHost(host); |
||
620 | throw new DriverException(PluginServices. |
||
621 | getText(this, "connect_error"), e, type); |
||
622 | } |
||
623 | catch (NoninvertibleTransformException e) { |
||
624 | 4222 | jaume | NotificationManager.addError("NotinvertibleTransform", e);
|
625 | 3746 | jaume | } |
626 | 4222 | jaume | return null; |
627 | 3746 | jaume | } |
628 | |||
629 | /**
|
||
630 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
|
||
631 | */
|
||
632 | public Rectangle2D getFullExtent() { |
||
633 | return fullExtent;
|
||
634 | } |
||
635 | |||
636 | /**
|
||
637 | 6050 | jaume | *
|
638 | 3746 | jaume | * @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage,
|
639 | * java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort,
|
||
640 | 5334 | jaume | * com.iver.cit.gvsig.fmap.operations.Cancellable)
|
641 | 3746 | jaume | */
|
642 | 6805 | jaume | private int callCount; // mess code, represents the amount of times the methods drawFixedSize or drawTile where tried for an extent |
643 | private static final int MAX_RETRY_TIMES = 5; // mess code, represents the max amount of retries allowed. |
||
644 | 3746 | jaume | public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
645 | Cancellable cancel,double scale) throws DriverException { |
||
646 | 6805 | jaume | callCount = 0; // mess code |
647 | 4222 | jaume | if (isWithinScale(scale)){
|
648 | Point2D p = viewPort.getOffset();
|
||
649 | // p will be (0, 0) when drawing a view or other when painting onto
|
||
650 | // the Layout.
|
||
651 | visualStatus.width = viewPort.getImageWidth(); |
||
652 | visualStatus.height = viewPort.getImageHeight(); |
||
653 | visualStatus.minX = viewPort.getAdjustedExtent().getMinX(); |
||
654 | visualStatus.minY = viewPort.getAdjustedExtent().getMinY(); |
||
655 | visualStatus.maxX = viewPort.getAdjustedExtent().getMaxX(); |
||
656 | visualStatus.maxY = viewPort.getAdjustedExtent().getMaxY(); |
||
657 | 6805 | jaume | |
658 | |||
659 | 4222 | jaume | if (isSizeFixed()) {
|
660 | // This condition handles those situations in which the server can
|
||
661 | // only give static extent and resolution maps despite we need
|
||
662 | // a specific BBOX and pixel WIDTH and HEIGHT
|
||
663 | drawFixedSize(g, viewPort, cancel); |
||
664 | |||
665 | } else {
|
||
666 | 5534 | nacho | if(mustTileDraw){
|
667 | Rectangle r = new Rectangle((int) p.getX(), (int) p.getY(), viewPort.getImageWidth(), viewPort.getImageHeight()); |
||
668 | Tiling tiles = new Tiling(maxTileDrawWidth, maxTileDrawHeight, r);
|
||
669 | tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
|
||
670 | for (int tileNr=0; tileNr < tiles.getNumTiles(); tileNr++) { |
||
671 | // drawing part
|
||
672 | try {
|
||
673 | ViewPort vp = tiles.getTileViewPort(viewPort, tileNr); |
||
674 | drawTile(g, vp, cancel); |
||
675 | } catch (NoninvertibleTransformException e) { |
||
676 | e.printStackTrace(); |
||
677 | } |
||
678 | 4222 | jaume | } |
679 | 5534 | nacho | }else
|
680 | drawTile(g, viewPort, cancel); |
||
681 | 4222 | jaume | } |
682 | 3841 | nacho | } |
683 | 4730 | jaume | // Runtime r = Runtime.getRuntime();
|
684 | // long mem = r.totalMemory() - r.freeMemory();
|
||
685 | // System.err.println("Memoria total: " + (mem / 1024) +"KB");
|
||
686 | 3841 | nacho | } |
687 | 6050 | jaume | |
688 | 4222 | jaume | private void drawFixedSize(Graphics2D g, ViewPort vp, Cancellable cancel) throws DriverException { |
689 | 6805 | jaume | callCount++; // mess code, it is not unusual a wms server to response an error which is completely
|
690 | // temporal and the response is available if we retry requesting.
|
||
691 | //
|
||
692 | |||
693 | |||
694 | 4222 | jaume | // This is the extent that will be requested
|
695 | Rectangle2D bBox = getFullExtent();
|
||
696 | 5409 | jaume | MyCancellable c = new MyCancellable(cancel);
|
697 | 6050 | jaume | |
698 | try {
|
||
699 | 4222 | jaume | wmsStatus.setExtent( bBox ); |
700 | wmsStatus.setFormat( m_Format ); |
||
701 | wmsStatus.setHeight( fixedSize.height ); |
||
702 | wmsStatus.setWidth( fixedSize.width ); |
||
703 | wmsStatus.setLayerNames(Utilities.createVector(layerQuery,",")); |
||
704 | wmsStatus.setSrs(m_SRS); |
||
705 | wmsStatus.setStyles(styles); |
||
706 | wmsStatus.setDimensions(dimensions); |
||
707 | wmsStatus.setTransparency(wmsTransparency); |
||
708 | wmsStatus.setOnlineResource((String) onlineResources.get("GetMap")); |
||
709 | 5409 | jaume | File f = getDriver().getMap(wmsStatus, c);
|
710 | if (f == null) |
||
711 | return;
|
||
712 | 4222 | jaume | String nameWorldFile = f.getPath() + getExtensionWorldFile();
|
713 | com.iver.andami.Utilities.createTemp(nameWorldFile, this.getDataWorldFile(bBox, fixedSize));
|
||
714 | 6050 | jaume | |
715 | 4222 | jaume | if(status!=null && firstLoad){ |
716 | status.applyStatus(this);
|
||
717 | firstLoad = false;
|
||
718 | } |
||
719 | 6050 | jaume | |
720 | 4222 | jaume | // And finally, obtain the extent intersecting the view and the BBox
|
721 | // to draw to.
|
||
722 | Rectangle2D extent = new Rectangle2D.Double(); |
||
723 | Rectangle2D.intersect(vp.getAdjustedExtent(), bBox, extent);
|
||
724 | 6050 | jaume | |
725 | 4222 | jaume | ViewPortData vpData = new ViewPortData(
|
726 | vp.getProjection(), new Extent(extent), fixedSize );
|
||
727 | vpData.setMat(vp.getAffineTransform()); |
||
728 | |||
729 | rasterProcess(g, vpData, f); |
||
730 | 6050 | jaume | |
731 | 4222 | jaume | } catch (ValidationException e) {
|
732 | 5409 | jaume | if (!c.isCanceled())
|
733 | 8765 | jjdelcerro | { |
734 | UnknownResponseFormatExceptionType type = |
||
735 | new UnknownResponseFormatExceptionType();
|
||
736 | type.setLayerName(getName()); |
||
737 | try {
|
||
738 | type.setDriverName("WMS Driver");
|
||
739 | } catch (Exception e1) { |
||
740 | e1.printStackTrace(); |
||
741 | } |
||
742 | type.setFormat(m_Format); |
||
743 | type.setHost(host); |
||
744 | type.setProtocol("WMS");
|
||
745 | DriverException exception = new DriverException("unknown_response_format", type); |
||
746 | throw exception;
|
||
747 | } |
||
748 | // azabala throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e);
|
||
749 | 4222 | jaume | } catch (UnsupportedVersionException e) {
|
750 | 8765 | jjdelcerro | if (!c.isCanceled()){
|
751 | UnsuportedProtocolVersionExceptionType type = |
||
752 | new UnsuportedProtocolVersionExceptionType();
|
||
753 | type.setLayerName(getName()); |
||
754 | try {
|
||
755 | type.setDriverName("WMS Driver");
|
||
756 | } catch (Exception ex){ |
||
757 | } |
||
758 | type.setUrl(host); |
||
759 | throw new DriverException(PluginServices.getText(this, "version_conflict"), e, type); |
||
760 | } |
||
761 | // azabala throw new DriverException(PluginServices.getText(this, "version_conflict"), e);
|
||
762 | 4222 | jaume | } catch (IOException e) { |
763 | 5409 | jaume | if (!c.isCanceled())
|
764 | 6818 | jaume | if (callCount<MAX_RETRY_TIMES) { // mess code |
765 | NotificationManager.addWarning("\n[ FLyrWMS.drawFixedSize() ] Failed in trying " + callCount + "/" + MAX_RETRY_TIMES + ")\n", null); // mess code |
||
766 | // I'll try again requesting up to MAX_RETRY_TIMES times before throw an error // mess code
|
||
767 | // (this is mess code, should be replaced by a layer status handler which is scheduled for version > 1.0) // mess code
|
||
768 | drawFixedSize(g, vp, cancel); // mess code
|
||
769 | } // mess code
|
||
770 | 8765 | jjdelcerro | |
771 | 6818 | jaume | if (callCount == 1) { // mess code |
772 | 8765 | jjdelcerro | ConnectionErrorExceptionType type = new ConnectionErrorExceptionType();
|
773 | type.setLayerName(getName()); |
||
774 | try {
|
||
775 | type.setDriverName("WMS Driver");
|
||
776 | } catch (Exception e1) { |
||
777 | } |
||
778 | type.setHost(host); |
||
779 | throw new DriverException(PluginServices. |
||
780 | getText(this, "connect_error"), e, type); |
||
781 | // azabala throw new DriverException(PluginServices.getText(this, "connect_error"), e);
|
||
782 | 6818 | jaume | } // mess code
|
783 | 8765 | jjdelcerro | |
784 | |||
785 | 4222 | jaume | } catch (WMSException e) {
|
786 | 5409 | jaume | if (!c.isCanceled()) {
|
787 | 6818 | jaume | if (callCount<MAX_RETRY_TIMES) { // mess code |
788 | NotificationManager.addWarning("\n[ FLyrWMS.drawFixedSize() ] Failed in trying " + callCount + "/" + MAX_RETRY_TIMES + ")\n", null); // mess code |
||
789 | // I'll try again requesting up to MAX_RETRY_TIMES times before throw an error // mess code
|
||
790 | // (this is mess code, should be replaced by a layer status handler which is scheduled for version > 1.0) // mess code
|
||
791 | drawFixedSize(g, vp, cancel); // mess code
|
||
792 | } // mess code
|
||
793 | if (callCount == 1) { // mess code |
||
794 | 8765 | jjdelcerro | // azabala JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage());
|
795 | WMSDriverExceptionType type = new WMSDriverExceptionType();
|
||
796 | type.setLayerName(getName()); |
||
797 | try {
|
||
798 | type.setDriverName("WMS Driver");
|
||
799 | } catch (Exception e1) { |
||
800 | } |
||
801 | type.setWcsStatus(this.wmsStatus);
|
||
802 | 6805 | jaume | if (!isPrinting)
|
803 | this.setVisible(false); |
||
804 | 8765 | jjdelcerro | throw new DriverException("Error WMS", e, type); |
805 | 6805 | jaume | |
806 | 8765 | jjdelcerro | |
807 | 6818 | jaume | } // mess code
|
808 | 5409 | jaume | } |
809 | 3841 | nacho | } |
810 | 6818 | jaume | callCount--; // mess code
|
811 | 4222 | jaume | } |
812 | 6050 | jaume | |
813 | 3841 | nacho | /**
|
814 | 4222 | jaume | * This is the method used to draw a tile in a WMS mosaic layer.
|
815 | 3841 | nacho | */
|
816 | 4222 | jaume | private void drawTile(Graphics2D g, ViewPort vp, Cancellable cancel) throws DriverException { |
817 | 6805 | jaume | callCount++; |
818 | 6050 | jaume | // Compute the query geometry
|
819 | 4222 | jaume | // 1. Check if it is within borders
|
820 | Rectangle2D extent = getFullExtent();
|
||
821 | 6426 | jaume | if ((vp.getAdjustedExtent().getMinX() > extent.getMaxX()) ||
|
822 | (vp.getAdjustedExtent().getMinY() > extent.getMaxY()) || |
||
823 | (vp.getAdjustedExtent().getMaxX() < extent.getMinX()) || |
||
824 | (vp.getAdjustedExtent().getMaxY() < extent.getMinY())) { |
||
825 | 4222 | jaume | return;
|
826 | } |
||
827 | 6050 | jaume | |
828 | 4222 | jaume | // 2. Compute extent to be requested.
|
829 | Rectangle2D bBox = new Rectangle2D.Double(); |
||
830 | 8907 | jaume | Rectangle2D.intersect(vp.getAdjustedExtent(), extent, bBox);
|
831 | 6050 | jaume | |
832 | 4222 | jaume | // 3. Compute size in pixels
|
833 | 6050 | jaume | double scalex = vp.getAffineTransform().getScaleX();
|
834 | double scaley = vp.getAffineTransform().getScaleY();
|
||
835 | 4222 | jaume | int wImg = (int) Math.ceil(Math.abs(bBox.getWidth() * scalex) + 1); |
836 | int hImg = (int) Math.ceil(Math.abs(bBox.getHeight() * scaley) + 1); |
||
837 | 6050 | jaume | |
838 | 4222 | jaume | Dimension sz = new Dimension(wImg, hImg); |
839 | |||
840 | if ((wImg <= 0) || (hImg <= 0)) { |
||
841 | return;
|
||
842 | } |
||
843 | 5409 | jaume | MyCancellable c = new MyCancellable(cancel);
|
844 | 6050 | jaume | |
845 | 5534 | nacho | try {
|
846 | 7642 | jaume | // wImg = vp.getImageWidth();
|
847 | // hImg = vp.getImageHeight();
|
||
848 | sz = new Dimension(wImg, hImg); |
||
849 | 6086 | jaume | Rectangle2D.intersect(vp.getAdjustedExtent(), extent, bBox);
|
850 | 6050 | jaume | |
851 | 6822 | jaume | |
852 | 4222 | jaume | wmsStatus.setExtent( bBox ); |
853 | wmsStatus.setFormat(m_Format); |
||
854 | wmsStatus.setHeight( hImg ); |
||
855 | wmsStatus.setWidth( wImg ); |
||
856 | wmsStatus.setLayerNames(Utilities.createVector(layerQuery,",")); |
||
857 | wmsStatus.setSrs(m_SRS); |
||
858 | wmsStatus.setStyles(styles); |
||
859 | wmsStatus.setDimensions(dimensions); |
||
860 | wmsStatus.setTransparency(wmsTransparency); |
||
861 | wmsStatus.setOnlineResource((String) onlineResources.get("GetMap")); |
||
862 | 6050 | jaume | |
863 | 8765 | jjdelcerro | // begin patch; Avoid to request too small tiles.
|
864 | // This generally occurs when printing
|
||
865 | 6822 | jaume | |
866 | if (wImg < minTilePrintWidth) {
|
||
867 | double wScale = (double) minTilePrintWidth / wImg; |
||
868 | wmsStatus.setWidth(minTilePrintWidth); |
||
869 | Rectangle2D sExtent = wmsStatus.getExtent();
|
||
870 | Point2D initialPoint = new Point2D.Double(sExtent.getX(), sExtent.getY()); |
||
871 | sExtent.setRect(sExtent.getX()*wScale, sExtent.getY(), sExtent.getWidth()*wScale, sExtent.getHeight()); |
||
872 | if (!bBox.contains(initialPoint)) {
|
||
873 | sExtent.setRect(sExtent.getX() - initialPoint.getX(), sExtent.getY(), sExtent.getWidth(), sExtent.getHeight()); |
||
874 | } |
||
875 | } |
||
876 | |||
877 | if (hImg < minTilePrintHeight) {
|
||
878 | double hScale = (double) minTilePrintHeight / hImg; |
||
879 | wmsStatus.setHeight(minTilePrintHeight); |
||
880 | Rectangle2D sExtent = wmsStatus.getExtent();
|
||
881 | Point2D initialPoint = new Point2D.Double(sExtent.getX(), sExtent.getY()); |
||
882 | sExtent.setRect(sExtent.getX(), sExtent.getY()*hScale, sExtent.getWidth(), sExtent.getHeight()*hScale); |
||
883 | if (!bBox.contains(initialPoint)) {
|
||
884 | sExtent.setRect(sExtent.getX(), sExtent.getY() - initialPoint.getY(), sExtent.getWidth(), sExtent.getHeight()); |
||
885 | } |
||
886 | } |
||
887 | |||
888 | // end patch
|
||
889 | 5409 | jaume | File f = getDriver().getMap(wmsStatus, c);
|
890 | if (f == null) |
||
891 | return;
|
||
892 | 4222 | jaume | String nameWordFile = f.getPath() + getExtensionWorldFile();
|
893 | com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWorldFile(bBox, sz));
|
||
894 | 7642 | jaume | |
895 | 4222 | jaume | ViewPortData vpData = new ViewPortData(
|
896 | vp.getProjection(), new Extent(bBox), sz );
|
||
897 | vpData.setMat(vp.getAffineTransform()); |
||
898 | |||
899 | rasterProcess(g, vpData, f); |
||
900 | 7642 | jaume | |
901 | 3840 | nacho | } catch (ValidationException e) {
|
902 | 8765 | jjdelcerro | //azabala
|
903 | // if (!c.isCanceled())
|
||
904 | // throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e);
|
||
905 | |||
906 | 5409 | jaume | if (!c.isCanceled())
|
907 | 8765 | jjdelcerro | { |
908 | UnknownResponseFormatExceptionType type = |
||
909 | new UnknownResponseFormatExceptionType();
|
||
910 | type.setLayerName(getName()); |
||
911 | try {
|
||
912 | type.setDriverName("WMS Driver");
|
||
913 | } catch (Exception e1) { |
||
914 | e1.printStackTrace(); |
||
915 | } |
||
916 | type.setFormat(m_Format); |
||
917 | type.setHost(host); |
||
918 | type.setProtocol("WMS");
|
||
919 | DriverException exception = new DriverException("unknown_response_format", type); |
||
920 | throw exception;
|
||
921 | } |
||
922 | 3840 | nacho | } catch (UnsupportedVersionException e) {
|
923 | 8765 | jjdelcerro | |
924 | // if (!c.isCanceled())
|
||
925 | // throw new DriverException(PluginServices.getText(this, "version_conflict"), e);
|
||
926 | |||
927 | if (!c.isCanceled()){
|
||
928 | UnsuportedProtocolVersionExceptionType type = |
||
929 | new UnsuportedProtocolVersionExceptionType();
|
||
930 | type.setLayerName(getName()); |
||
931 | try {
|
||
932 | type.setDriverName("WMS Driver");
|
||
933 | } catch (Exception ex){ |
||
934 | } |
||
935 | type.setUrl(host); |
||
936 | throw new DriverException(PluginServices.getText(this, "version_conflict"), e, type); |
||
937 | } |
||
938 | |||
939 | 3840 | nacho | } catch (IOException e) { |
940 | 8765 | jjdelcerro | /*azabala
|
941 | 5409 | jaume | if (!c.isCanceled())
|
942 | 6805 | jaume | if (callCount<MAX_RETRY_TIMES) {
|
943 | NotificationManager.addWarning("\n[ FLyrWMS.drawFixedSize() ] Failed in trying " + callCount + "/" + MAX_RETRY_TIMES + ")\n", null);
|
||
944 | // I'll try again requesting up to MAX_RETRY_TIMES times before throw an error
|
||
945 | // (this is mess code, should be replaced by a layer status handler which is scheduled for version > 1.0)
|
||
946 | 7075 | jaume | drawTile(g, vp, cancel);
|
947 | 6805 | jaume | }
|
948 | if (callCount == 1) {
|
||
949 | throw new DriverException(PluginServices.getText(this, "connect_error"), e);
|
||
950 | }
|
||
951 | 8765 | jjdelcerro | */
|
952 | if (!c.isCanceled()){
|
||
953 | if (callCount<MAX_RETRY_TIMES) { // mess code |
||
954 | NotificationManager.addWarning("\n[ FLyrWMS.drawFixedSize() ] Failed in trying " + callCount + "/" + MAX_RETRY_TIMES + ")\n", null); // mess code |
||
955 | // I'll try again requesting up to MAX_RETRY_TIMES times before throw an error // mess code
|
||
956 | // (this is mess code, should be replaced by a layer status handler which is scheduled for version > 1.0) // mess code
|
||
957 | |||
958 | //FIXME Aqu? deberiamos llamar a drawTile o a drawFixedSize????
|
||
959 | drawFixedSize(g, vp, cancel); // mess code
|
||
960 | } // mess code
|
||
961 | } |
||
962 | if (callCount == 1) { // mess code |
||
963 | ConnectionErrorExceptionType type = new ConnectionErrorExceptionType();
|
||
964 | type.setLayerName(getName()); |
||
965 | try {
|
||
966 | type.setDriverName("WMS Driver");
|
||
967 | } catch (Exception e1) {} |
||
968 | type.setHost(host); |
||
969 | throw new DriverException(PluginServices. |
||
970 | getText(this, "connect_error"), e, type); |
||
971 | }//if
|
||
972 | 3840 | nacho | } catch (WMSException e) {
|
973 | 8765 | jjdelcerro | /*azabala
|
974 | 5409 | jaume | if (!c.isCanceled()) {
|
975 | 6805 | jaume | if (callCount<MAX_RETRY_TIMES) {
|
976 | NotificationManager.addWarning("\n[ FLyrWMS.drawTile() ] Failed in trying " + callCount + "/" + MAX_RETRY_TIMES +" \n", null);
|
||
977 | // I'll try again requesting up to MAX_RETRY_TIMES times before throw an error
|
||
978 | // (this is mess code, should be replaced by a layer status handler which is scheduled for version > 1.0)
|
||
979 | drawTile(g, vp, cancel);
|
||
980 | }
|
||
981 | if (callCount == 1) {
|
||
982 | 6939 | jaume | if (!isPrinting) {
|
983 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage());
|
||
984 | 6805 | jaume | this.setVisible(false);
|
985 | 6939 | jaume | }
|
986 | 6805 | jaume | }
|
987 | 5409 | jaume | }
|
988 | 8765 | jjdelcerro | */
|
989 | if (!c.isCanceled()) {
|
||
990 | if (callCount<MAX_RETRY_TIMES) { // mess code |
||
991 | NotificationManager.addWarning("\n[ FLyrWMS.drawFixedSize() ] Failed in trying " + callCount + "/" + MAX_RETRY_TIMES + ")\n", null); // mess code |
||
992 | // I'll try again requesting up to MAX_RETRY_TIMES times before throw an error // mess code
|
||
993 | // (this is mess code, should be replaced by a layer status handler which is scheduled for version > 1.0) // mess code
|
||
994 | drawTile(g, vp, cancel); |
||
995 | } // mess code
|
||
996 | if (callCount == 1) { // mess code |
||
997 | // azabala JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage());
|
||
998 | WMSDriverExceptionType type = new WMSDriverExceptionType();
|
||
999 | type.setLayerName(getName()); |
||
1000 | try {
|
||
1001 | type.setDriverName("WMS Driver");
|
||
1002 | } catch (Exception e1) { |
||
1003 | } |
||
1004 | type.setWcsStatus(this.wmsStatus);
|
||
1005 | if (!isPrinting)
|
||
1006 | this.setVisible(false); |
||
1007 | throw new DriverException("Error WMS", e, type); |
||
1008 | |||
1009 | |||
1010 | } //if
|
||
1011 | }//if
|
||
1012 | }//catch
|
||
1013 | 6805 | jaume | callCount--; |
1014 | 3746 | jaume | } |
1015 | 4222 | jaume | |
1016 | /**
|
||
1017 | * Obtiene la extensi?n del fichero de georreferenciaci?n
|
||
1018 | 6986 | cesar | * @return String con la extensi?n del fichero de georreferenciaci?n dependiendo
|
1019 | 6050 | jaume | * del valor del formato obtenido del servidor. Por defecto asignaremos un .wld
|
1020 | 4222 | jaume | */
|
1021 | private String getExtensionWorldFile(){ |
||
1022 | String extWorldFile = ".wld"; |
||
1023 | if(m_Format.equals("image/tif") || m_Format.equals("image/tiff")) |
||
1024 | extWorldFile = ".tfw";
|
||
1025 | if(m_Format.equals("image/jpeg")) |
||
1026 | extWorldFile = ".jpgw";
|
||
1027 | return extWorldFile;
|
||
1028 | } |
||
1029 | 6050 | jaume | |
1030 | 3746 | jaume | /**
|
1031 | 4222 | jaume | * Calcula el contenido del fichero de georreferenciaci?n de una imagen.
|
1032 | * @param bBox Tama?o y posici?n de la imagen (en coordenadas de usuario)
|
||
1033 | * @param sz Tama?o de la imagen en pixeles.
|
||
1034 | * @return el 'WorldFile', como String.
|
||
1035 | 3746 | jaume | * @throws IOException
|
1036 | */
|
||
1037 | 4222 | jaume | public String getDataWorldFile(Rectangle2D bBox, Dimension sz) throws IOException { |
1038 | StringBuffer data = new StringBuffer(); |
||
1039 | data.append((bBox.getMaxX() - bBox.getMinX())/(sz.getWidth() - 1)+"\n"); |
||
1040 | data.append("0.0\n");
|
||
1041 | data.append("0.0\n");
|
||
1042 | 8765 | jjdelcerro | data.append("-"+(bBox.getMaxY() - bBox.getMinY())/(sz.getHeight() - 1)+"\n"); |
1043 | 4222 | jaume | data.append(""+bBox.getMinX()+"\n"); |
1044 | 8765 | jjdelcerro | data.append(""+bBox.getMaxY()+"\n"); |
1045 | 4222 | jaume | return data.toString();
|
1046 | 3746 | jaume | } |
1047 | 6050 | jaume | |
1048 | 3746 | jaume | /**
|
1049 | 4222 | jaume | * Dibuja una imagen usando PxRaster
|
1050 | * @param g Graphics2D en el que hay que dibujar.
|
||
1051 | * @param vpData Par?metros de visualizaci?n
|
||
1052 | * @param file La imagen en cuesti?n.
|
||
1053 | */
|
||
1054 | 9056 | nacho | private void rasterProcess(Graphics2D g, ViewPortData vpData, File file) throws DriverException { |
1055 | 6050 | jaume | |
1056 | //Creamos el PxRaster
|
||
1057 | 9056 | nacho | try {
|
1058 | rasterFile = new GdalFile(vpData.getProjection(), file.getAbsolutePath());
|
||
1059 | } catch (NotSupportedExtensionException e) {
|
||
1060 | throw new DriverException("Open File Error"); |
||
1061 | } |
||
1062 | 3746 | jaume | raster = new PxRaster(rasterFile, null, rasterFile.getExtent()); |
1063 | 9056 | nacho | grid = new Grid(rasterFile);
|
1064 | grid.addRenderizer(raster); |
||
1065 | |||
1066 | if(status != null && firstLoad){ |
||
1067 | 7106 | nacho | status.applyStatus(this);
|
1068 | firstLoad = false;
|
||
1069 | } |
||
1070 | 7642 | jaume | |
1071 | 3746 | jaume | //Recuperamos la pila de filtros si ya hubiese sido cargado antes
|
1072 | if(this.filterStack!=null) |
||
1073 | raster.filterStack = this.filterStack;
|
||
1074 | 6050 | jaume | |
1075 | 3746 | jaume | raster.setTransparency(false);
|
1076 | 6050 | jaume | |
1077 | 3746 | jaume | //Asignamos transparencia y orden de bandas
|
1078 | 9056 | nacho | if(this.transparency == -1 && !firstLoad); |
1079 | 3746 | jaume | else
|
1080 | raster.setTransparency(this.transparency);
|
||
1081 | 6050 | jaume | |
1082 | 3746 | jaume | raster.setBand(GeoRasterFile.RED_BAND,rband); |
1083 | raster.setBand(GeoRasterFile.GREEN_BAND, gband); |
||
1084 | raster.setBand(GeoRasterFile.BLUE_BAND, bband); |
||
1085 | 6050 | jaume | |
1086 | 3746 | jaume | //Despues del primer pxRaster asignamos el stackManager guardado para los siguientes.
|
1087 | 6050 | jaume | //Con esto conseguimos asignar los cambios que se hayan producido desde el cuadro de
|
1088 | 3746 | jaume | //propiedades cuando creamos un nuevo pxRaster
|
1089 | if(this.stackManager != null) |
||
1090 | 6050 | jaume | raster.setStackManager(this.stackManager);
|
1091 | |||
1092 | 4378 | nacho | if(visualStatus != null){ |
1093 | visualStatus.bandCount = raster.getBandCount(); |
||
1094 | visualStatus.dataType = raster.getDataType(); |
||
1095 | } |
||
1096 | 3841 | nacho | |
1097 | 3746 | jaume | raster.draw(g, vpData); |
1098 | 6050 | jaume | |
1099 | 3746 | jaume | //En el primer pxRaster de una imagen obtenemos el Stack Manager para poder modificarlo
|
1100 | //si queremos desde las propiedades
|
||
1101 | 6050 | jaume | |
1102 | 3746 | jaume | if(this.stackManager == null) |
1103 | 6050 | jaume | this.stackManager = raster.getStackManager();
|
1104 | |||
1105 | 3746 | jaume | if(this.filterStack == null) |
1106 | this.filterStack = raster.filterStack;
|
||
1107 | 6050 | jaume | |
1108 | 4329 | ldiaz | //rasterFile.close();
|
1109 | 3746 | jaume | } |
1110 | 6050 | jaume | |
1111 | 3746 | jaume | /**
|
1112 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D,
|
||
1113 | * com.iver.cit.gvsig.fmap.ViewPort,
|
||
1114 | 5334 | jaume | * com.iver.cit.gvsig.fmap.operations.Cancellable)
|
1115 | 3746 | jaume | */
|
1116 | 9013 | caballero | public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
1117 | 3746 | jaume | throws DriverException {
|
1118 | 6050 | jaume | if (isVisible() && isWithinScale(scale)){
|
1119 | 3746 | jaume | isPrinting = true;
|
1120 | if (!mustTilePrint) {
|
||
1121 | draw(null, g, viewPort, cancel,scale);
|
||
1122 | } else {
|
||
1123 | // Para no pedir imagenes demasiado grandes, vamos
|
||
1124 | // a hacer lo mismo que hace EcwFile: chunkear.
|
||
1125 | 4222 | jaume | // Llamamos a drawView con cuadraditos m?s peque?os
|
1126 | 3746 | jaume | // del BufferedImage ni caso, cuando se imprime viene con null
|
1127 | 6050 | jaume | |
1128 | 6986 | cesar | Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, g.getClipBounds());
|
1129 | 3746 | jaume | tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
|
1130 | for (int tileNr=0; tileNr < tiles.getNumTiles(); tileNr++) { |
||
1131 | // Parte que dibuja
|
||
1132 | try {
|
||
1133 | ViewPort vp = tiles.getTileViewPort(viewPort, tileNr); |
||
1134 | 4222 | jaume | drawTile(g, vp, cancel); |
1135 | 3746 | jaume | } catch (NoninvertibleTransformException e) { |
1136 | e.printStackTrace(); |
||
1137 | } |
||
1138 | } |
||
1139 | } |
||
1140 | isPrinting = false;
|
||
1141 | } |
||
1142 | } |
||
1143 | 6050 | jaume | |
1144 | 3746 | jaume | public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) |
1145 | throws DriverException {
|
||
1146 | draw(null, g, viewPort, cancel,scale);
|
||
1147 | } |
||
1148 | |||
1149 | /**
|
||
1150 | * Devuelve el FMapWMSDriver.
|
||
1151 | *
|
||
1152 | * @return FMapWMSDriver
|
||
1153 | *
|
||
1154 | * @throws IllegalStateException
|
||
1155 | * @throws ValidationException
|
||
1156 | * @throws UnsupportedVersionException
|
||
1157 | * @throws IOException
|
||
1158 | */
|
||
1159 | private FMapWMSDriver getDriver()
|
||
1160 | 6050 | jaume | throws IllegalStateException, ValidationException, |
1161 | 3746 | jaume | UnsupportedVersionException, IOException {
|
1162 | 5334 | jaume | return FMapWMSDriverFactory.getFMapDriverForURL(host);
|
1163 | 3746 | jaume | } |
1164 | 6050 | jaume | |
1165 | 3746 | jaume | /**
|
1166 | * Devuelve el FMapWMSDriver.
|
||
1167 | *
|
||
1168 | * @return FMapWMSDriver
|
||
1169 | *
|
||
1170 | * @throws IllegalStateException
|
||
1171 | * @throws ValidationException
|
||
1172 | * @throws UnsupportedVersionException
|
||
1173 | * @throws IOException
|
||
1174 | */
|
||
1175 | public void setDriver(FMapWMSDriver drv) { |
||
1176 | wms = drv; |
||
1177 | } |
||
1178 | |||
1179 | /**
|
||
1180 | * Devuelve el URL.
|
||
1181 | *
|
||
1182 | * @return URL.
|
||
1183 | */
|
||
1184 | public URL getHost() { |
||
1185 | return host;
|
||
1186 | } |
||
1187 | |||
1188 | /**
|
||
1189 | * Inserta el URL.
|
||
1190 | *
|
||
1191 | * @param host URL.
|
||
1192 | */
|
||
1193 | public void setHost(URL host) { |
||
1194 | this.host = host;
|
||
1195 | } |
||
1196 | |||
1197 | /**
|
||
1198 | * Devuelve la informaci?n de la consulta.
|
||
1199 | *
|
||
1200 | * @return String.
|
||
1201 | */
|
||
1202 | public String getInfoLayerQuery() { |
||
1203 | return infoLayerQuery;
|
||
1204 | } |
||
1205 | |||
1206 | /**
|
||
1207 | 4222 | jaume | * Inserta la informaci?n de la consulta.
|
1208 | 3746 | jaume | *
|
1209 | * @param infoLayerQuery String.
|
||
1210 | */
|
||
1211 | public void setInfoLayerQuery(String infoLayerQuery) { |
||
1212 | this.infoLayerQuery = infoLayerQuery;
|
||
1213 | } |
||
1214 | |||
1215 | /**
|
||
1216 | * Devuelve la consulta.
|
||
1217 | *
|
||
1218 | * @return String.
|
||
1219 | */
|
||
1220 | public String getLayerQuery() { |
||
1221 | return layerQuery;
|
||
1222 | } |
||
1223 | |||
1224 | /**
|
||
1225 | * Inserta la consulta.
|
||
1226 | *
|
||
1227 | * @param layerQuery consulta.
|
||
1228 | */
|
||
1229 | public void setLayerQuery(String layerQuery) { |
||
1230 | this.layerQuery = layerQuery;
|
||
1231 | } |
||
1232 | |||
1233 | /**
|
||
1234 | * Devuelve el formato.
|
||
1235 | *
|
||
1236 | * @return Formato.
|
||
1237 | */
|
||
1238 | public String getFormat() { |
||
1239 | return m_Format;
|
||
1240 | } |
||
1241 | |||
1242 | /**
|
||
1243 | * Inserta el formato.
|
||
1244 | *
|
||
1245 | * @param format Formato.
|
||
1246 | */
|
||
1247 | public void setFormat(String format) { |
||
1248 | m_Format = format; |
||
1249 | } |
||
1250 | |||
1251 | /**
|
||
1252 | * Devuelve el SRS.
|
||
1253 | *
|
||
1254 | * @return SRS.
|
||
1255 | */
|
||
1256 | public String getSRS() { |
||
1257 | return m_SRS;
|
||
1258 | } |
||
1259 | |||
1260 | /**
|
||
1261 | * Inserta el SRS.
|
||
1262 | *
|
||
1263 | * @param m_srs SRS.
|
||
1264 | */
|
||
1265 | public void setSRS(String m_srs) { |
||
1266 | m_SRS = m_srs; |
||
1267 | } |
||
1268 | |||
1269 | /**
|
||
1270 | 4222 | jaume | * Inserta la extensi?n total de la capa.
|
1271 | 3746 | jaume | *
|
1272 | 4222 | jaume | * @param fullExtent Rect?ngulo.
|
1273 | 3746 | jaume | */
|
1274 | public void setFullExtent(Rectangle2D fullExtent) { |
||
1275 | this.fullExtent = fullExtent;
|
||
1276 | } |
||
1277 | 6050 | jaume | |
1278 | 3746 | jaume | public HashMap getProperties() { |
1279 | HashMap info = new HashMap(); |
||
1280 | String[] layerNames = getLayerQuery().split(","); |
||
1281 | Vector layers = new Vector(layerNames.length); |
||
1282 | try {
|
||
1283 | 5409 | jaume | if(getDriver().connect(null)){ |
1284 | 3746 | jaume | for (int i = 0; i < layerNames.length; i++) { |
1285 | 5410 | jaume | layers.add(i, getDriver().getLayer(layerNames[i])); |
1286 | 3746 | jaume | } |
1287 | 4222 | jaume | info.put("name", getName());
|
1288 | 3746 | jaume | info.put("selectedLayers", layers);
|
1289 | info.put("host", getHost());
|
||
1290 | info.put("srs", getSRS());
|
||
1291 | info.put("format", getFormat());
|
||
1292 | info.put("wmsTransparency", new Boolean(wmsTransparency)); |
||
1293 | info.put("styles", styles);
|
||
1294 | info.put("dimensions", dimensions);
|
||
1295 | 4222 | jaume | info.put("fixedSize", fixedSize);
|
1296 | 3746 | jaume | return info;
|
1297 | } |
||
1298 | } catch (Exception e) { |
||
1299 | e.printStackTrace(); |
||
1300 | } |
||
1301 | return null; |
||
1302 | } |
||
1303 | 6050 | jaume | |
1304 | 3746 | jaume | /**
|
1305 | * Asignar el estado del raster
|
||
1306 | * @param status
|
||
1307 | */
|
||
1308 | public void setStatus(StatusRasterInterface status){ |
||
1309 | this.status = status;
|
||
1310 | } |
||
1311 | 6050 | jaume | |
1312 | 3746 | jaume | /**
|
1313 | * Obtiene el estado del raster
|
||
1314 | * @return
|
||
1315 | */
|
||
1316 | public StatusRasterInterface getStatus(){
|
||
1317 | return this.status; |
||
1318 | } |
||
1319 | 6050 | jaume | |
1320 | 3746 | jaume | /* (non-Javadoc)
|
1321 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getAttributes()
|
||
1322 | */
|
||
1323 | public ArrayList getAttributes() { |
||
1324 | if(rasterFile != null){ |
||
1325 | ArrayList attr = new ArrayList(); |
||
1326 | 4378 | nacho | String dataType = "Byte"; |
1327 | 3746 | jaume | if (rasterFile.getDataType() == DataBuffer.TYPE_BYTE) dataType = "Byte"; |
1328 | 4378 | nacho | else if (visualStatus.dataType == DataBuffer.TYPE_SHORT) |
1329 | 3746 | jaume | dataType = "Short";
|
1330 | 4378 | nacho | else if (visualStatus.dataType == DataBuffer.TYPE_USHORT) |
1331 | 3746 | jaume | dataType = "Unsigned Short";
|
1332 | 4378 | nacho | else if (visualStatus.dataType == DataBuffer.TYPE_INT) |
1333 | 3746 | jaume | dataType = "Integer";
|
1334 | 4378 | nacho | else if (visualStatus.dataType == DataBuffer.TYPE_FLOAT) |
1335 | 3746 | jaume | dataType = "Float";
|
1336 | 4378 | nacho | else if (visualStatus.dataType == DataBuffer.TYPE_DOUBLE) |
1337 | 3746 | jaume | dataType = "Double";
|
1338 | else
|
||
1339 | dataType = "Unknown";
|
||
1340 | 4378 | nacho | |
1341 | 3746 | jaume | Object [][] a = { |
1342 | {"Filename",rasterFile.getName().substring(rasterFile.getName().lastIndexOf("/")+1, rasterFile.getName().length())}, |
||
1343 | 4378 | nacho | {"Filesize",new Long(0)}, |
1344 | {"Width",new Integer((int)this.getWidth())}, |
||
1345 | {"Height", new Integer((int)this.getHeight())}, |
||
1346 | {"Bands", new Integer(visualStatus.bandCount)}, |
||
1347 | {"BandDataType", dataType}
|
||
1348 | 3746 | jaume | }; |
1349 | 4378 | nacho | for (int i=0; i<a.length; i++) |
1350 | 3746 | jaume | attr.add(a[i]); |
1351 | 4378 | nacho | |
1352 | 3746 | jaume | return attr;
|
1353 | } |
||
1354 | return null; |
||
1355 | } |
||
1356 | 6050 | jaume | |
1357 | 3746 | jaume | /* (non-Javadoc)
|
1358 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getFilterStack()
|
||
1359 | */
|
||
1360 | public RasterFilterStack getFilterStack() {
|
||
1361 | if(raster!=null) |
||
1362 | return raster.filterStack;
|
||
1363 | return null; |
||
1364 | } |
||
1365 | /* (non-Javadoc)
|
||
1366 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getHeight()
|
||
1367 | */
|
||
1368 | public double getHeight() { |
||
1369 | 4222 | jaume | return visualStatus.height;
|
1370 | 3746 | jaume | } |
1371 | 6050 | jaume | |
1372 | 3746 | jaume | /* (non-Javadoc)
|
1373 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMaxX()
|
||
1374 | */
|
||
1375 | public double getMaxX() { |
||
1376 | 4222 | jaume | return visualStatus.maxX;
|
1377 | 3746 | jaume | } |
1378 | 6050 | jaume | |
1379 | 3746 | jaume | /* (non-Javadoc)
|
1380 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMaxY()
|
||
1381 | */
|
||
1382 | public double getMaxY() { |
||
1383 | 4222 | jaume | return visualStatus.maxY;
|
1384 | 3746 | jaume | } |
1385 | 6050 | jaume | |
1386 | 3746 | jaume | /* (non-Javadoc)
|
1387 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMinX()
|
||
1388 | */
|
||
1389 | public double getMinX() { |
||
1390 | 4222 | jaume | return visualStatus.minX;
|
1391 | 3746 | jaume | } |
1392 | 6050 | jaume | |
1393 | 3746 | jaume | /* (non-Javadoc)
|
1394 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMinY()
|
||
1395 | */
|
||
1396 | public double getMinY() { |
||
1397 | 4222 | jaume | return visualStatus.minY;
|
1398 | 3746 | jaume | } |
1399 | /* (non-Javadoc)
|
||
1400 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getPixel(double, double)
|
||
1401 | */
|
||
1402 | public int[] getPixel(double wcx, double wcy) { |
||
1403 | if(getPxRaster() != null) |
||
1404 | return getPxRaster().getPixel(wcx, wcy);
|
||
1405 | return null; |
||
1406 | } |
||
1407 | /* (non-Javadoc)
|
||
1408 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getSource()
|
||
1409 | */
|
||
1410 | public RasterAdapter getSource() {
|
||
1411 | return null; |
||
1412 | } |
||
1413 | /* (non-Javadoc)
|
||
1414 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getWidth()
|
||
1415 | */
|
||
1416 | public double getWidth() { |
||
1417 | 4222 | jaume | return visualStatus.width;
|
1418 | 3746 | jaume | } |
1419 | /* (non-Javadoc)
|
||
1420 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setBand(int, int)
|
||
1421 | */
|
||
1422 | public void setBand(int flag, int nBand) { |
||
1423 | switch(flag){
|
||
1424 | case GeoRasterFile.RED_BAND:setBandR(nBand);break; |
||
1425 | case GeoRasterFile.GREEN_BAND:setBandG(nBand);break; |
||
1426 | case GeoRasterFile.BLUE_BAND:setBandB(nBand);break; |
||
1427 | } |
||
1428 | } |
||
1429 | /* (non-Javadoc)
|
||
1430 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setFilterStack(org.cresques.io.raster.RasterFilterStack)
|
||
1431 | */
|
||
1432 | public void setFilterStack(RasterFilterStack stack) { |
||
1433 | this.filterStack = stack;
|
||
1434 | } |
||
1435 | /* (non-Javadoc)
|
||
1436 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setPos(int, int)
|
||
1437 | */
|
||
1438 | public void setPos(int x, int y) { |
||
1439 | this.posX = x;
|
||
1440 | this.posY = y;
|
||
1441 | } |
||
1442 | 6050 | jaume | |
1443 | 3746 | jaume | /* (non-Javadoc)
|
1444 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setPosWC(double, double)
|
||
1445 | */
|
||
1446 | public void setPosWC(double x, double y) { |
||
1447 | this.posXWC = x;
|
||
1448 | this.posYWC = y;
|
||
1449 | } |
||
1450 | 6050 | jaume | |
1451 | 3746 | jaume | /* (non-Javadoc)
|
1452 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setRGB(int, int, int)
|
||
1453 | */
|
||
1454 | public void setRGB(int r, int g, int b) { |
||
1455 | this.r = r;
|
||
1456 | this.g = g;
|
||
1457 | this.b = b;
|
||
1458 | } |
||
1459 | /* (non-Javadoc)
|
||
1460 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setSource(com.iver.cit.gvsig.fmap.layers.RasterAdapter)
|
||
1461 | */
|
||
1462 | public void setSource(RasterAdapter ra) { |
||
1463 | } |
||
1464 | /**
|
||
1465 | * @return Returns the raster.
|
||
1466 | */
|
||
1467 | public PxRaster getPxRaster() {
|
||
1468 | return raster;
|
||
1469 | } |
||
1470 | /**
|
||
1471 | * @return Returns the rasterFile.
|
||
1472 | */
|
||
1473 | public GeoRasterFile getGeoRasterFile() {
|
||
1474 | return rasterFile;
|
||
1475 | } |
||
1476 | 6050 | jaume | |
1477 | 3746 | jaume | public void setTransparency(int trans) { |
1478 | this.transparency = trans;
|
||
1479 | } |
||
1480 | 6050 | jaume | |
1481 | 3746 | jaume | /**
|
1482 | * Sets the R-band.
|
||
1483 | 6050 | jaume | *
|
1484 | 3746 | jaume | * Asigna la banda R.
|
1485 | * @param r
|
||
1486 | */
|
||
1487 | public void setBandR(int r){ |
||
1488 | this.rband = r;
|
||
1489 | } |
||
1490 | 6050 | jaume | |
1491 | 3746 | jaume | /**
|
1492 | * Sets the G-band.
|
||
1493 | 6050 | jaume | *
|
1494 | 3746 | jaume | * Asigna la banda G
|
1495 | * @param g
|
||
1496 | */
|
||
1497 | public void setBandG(int g){ |
||
1498 | this.gband = g;
|
||
1499 | } |
||
1500 | 6050 | jaume | |
1501 | 3746 | jaume | /**
|
1502 | * Sets the B-band.
|
||
1503 | 6050 | jaume | *
|
1504 | 3746 | jaume | * Asigna la banda B
|
1505 | * @param b
|
||
1506 | */
|
||
1507 | public void setBandB(int b){ |
||
1508 | this.bband = b;
|
||
1509 | } |
||
1510 | |||
1511 | /**
|
||
1512 | * @return Returns the wmsTransparency.
|
||
1513 | */
|
||
1514 | 4222 | jaume | public boolean isWmsTransparent() { |
1515 | 3746 | jaume | return wmsTransparency;
|
1516 | } |
||
1517 | |||
1518 | /**
|
||
1519 | * @param wmsTransparency The wmsTransparency to set.
|
||
1520 | */
|
||
1521 | public void setWmsTransparency(boolean wmsTransparency) { |
||
1522 | this.wmsTransparency = wmsTransparency;
|
||
1523 | } |
||
1524 | |||
1525 | 3842 | nacho | /**
|
1526 | 3746 | jaume | * @param styles
|
1527 | */
|
||
1528 | public void setStyles(Vector styles) { |
||
1529 | 3842 | nacho | //laura:
|
1530 | //layer query is built with the layer in reverse order
|
||
1531 | // so here we build the styles upside-down.
|
||
1532 | if (styles != null) |
||
1533 | { |
||
1534 | this.styles = new Vector(); |
||
1535 | for(int i = styles.size()-1; i>=0; i--) |
||
1536 | { |
||
1537 | this.styles.add(styles.elementAt(i));
|
||
1538 | } |
||
1539 | } |
||
1540 | 3746 | jaume | } |
1541 | 6050 | jaume | |
1542 | 3746 | jaume | /**
|
1543 | 4222 | jaume | * Sets the dimension vector that is a list of key-value pairs containing
|
1544 | * the name of the dimension and the value for it
|
||
1545 | 3746 | jaume | * @param dimensions
|
1546 | */
|
||
1547 | public void setDimensions(Vector dimensions) { |
||
1548 | this.dimensions = dimensions;
|
||
1549 | } |
||
1550 | 4222 | jaume | |
1551 | /**
|
||
1552 | * Sets the set of URLs that should be accessed for each operation performed
|
||
1553 | * to the server.
|
||
1554 | 6050 | jaume | *
|
1555 | 4222 | jaume | * @param onlineResources
|
1556 | */
|
||
1557 | public void setOnlineResources(Hashtable onlineResources) { |
||
1558 | this.onlineResources = onlineResources;
|
||
1559 | } |
||
1560 | 6050 | jaume | |
1561 | 8765 | jjdelcerro | /**
|
1562 | * Gets the URL that should be accessed for an operation performed
|
||
1563 | * to the server.
|
||
1564 | *
|
||
1565 | * @param onlineResources
|
||
1566 | */
|
||
1567 | public String getOnlineResource(String operation) { |
||
1568 | return ((String) onlineResources.get(operation)); |
||
1569 | } |
||
1570 | |||
1571 | 4222 | jaume | /**
|
1572 | * When a server is not fully featured and it only can serve constant map
|
||
1573 | * sizes this value must be set. It expresses the size in pixels (width, height)
|
||
1574 | * that the map will be requested.
|
||
1575 | * @param Dimension sz
|
||
1576 | */
|
||
1577 | public void setFixedSize(Dimension sz) { |
||
1578 | fixedSize = sz; |
||
1579 | } |
||
1580 | 6050 | jaume | |
1581 | 4222 | jaume | /**
|
1582 | * Tells whether if this layer must deal with the server with the constant-size
|
||
1583 | * limitations or not.
|
||
1584 | * @return boolean.
|
||
1585 | */
|
||
1586 | private boolean isSizeFixed() { |
||
1587 | return fixedSize != null && fixedSize.getWidth() > 0 && fixedSize.getHeight() > 0; |
||
1588 | } |
||
1589 | |||
1590 | /**
|
||
1591 | * If it is true, this layer accepts GetFeatureInfo operations. This WMS operations
|
||
1592 | * maps to FMap's infoByPoint(p) operation.
|
||
1593 | * @param b
|
||
1594 | */
|
||
1595 | public void setQueryable(boolean b) { |
||
1596 | queryable = b; |
||
1597 | } |
||
1598 | 4730 | jaume | |
1599 | /**
|
||
1600 | * Creates the part of a OGC's MapContext document that would describe this
|
||
1601 | * layer(s).
|
||
1602 | * @param version, The desired version of the resulting document. (1.1.0)
|
||
1603 | * @return String containing the xml.
|
||
1604 | 6050 | jaume | * @throws UnsupportedVersionException
|
1605 | 4730 | jaume | */
|
1606 | 4917 | jaume | public String toMapContext(String mapContextVersion) { |
1607 | 4730 | jaume | XmlBuilder xml = new XmlBuilder();
|
1608 | FMapWMSDriver drv; |
||
1609 | try {
|
||
1610 | drv = getDriver(); |
||
1611 | } catch (Exception e) { |
||
1612 | return xml.toString();
|
||
1613 | 6050 | jaume | } |
1614 | 4730 | jaume | String[] layerNames = getLayerQuery().split(","); |
1615 | 6050 | jaume | String[] styleNames = (String[]) styles.toArray(new String[0]); |
1616 | 4730 | jaume | for (int i = 0; i < layerNames.length; i++) { |
1617 | WMSLayerNode layer = drv.getLayer(layerNames[i]); |
||
1618 | 4917 | jaume | HashMap xmlAttrs = new HashMap(); |
1619 | 6050 | jaume | |
1620 | 4833 | jaume | // <Layer>
|
1621 | 4917 | jaume | xmlAttrs.put(WebMapContextTags.HIDDEN, !isVisible()+"");
|
1622 | xmlAttrs.put(WebMapContextTags.QUERYABLE, queryable+"");
|
||
1623 | 5409 | jaume | xml.openTag(WebMapContextTags.LAYER, xmlAttrs); |
1624 | xmlAttrs.clear(); |
||
1625 | 4917 | jaume | if (mapContextVersion.equals("1.1.0") || mapContextVersion.equals("1.0.0")) { |
1626 | 4730 | jaume | // <Server>
|
1627 | 4876 | jaume | xmlAttrs.put(WebMapContextTags.SERVICE, WebMapContextTags.WMS); |
1628 | xmlAttrs.put(WebMapContextTags.VERSION, drv.getVersion()); |
||
1629 | xmlAttrs.put(WebMapContextTags.SERVER_TITLE, drv.getServiceTitle()); |
||
1630 | xml.openTag(WebMapContextTags.SERVER, xmlAttrs); |
||
1631 | 4730 | jaume | xmlAttrs.clear(); |
1632 | 6050 | jaume | |
1633 | 4730 | jaume | // <OnlineResource>
|
1634 | 4876 | jaume | xmlAttrs.put(WebMapContextTags.XLINK_TYPE, "simple");
|
1635 | xmlAttrs.put(WebMapContextTags.XLINK_HREF, getHost().toString()); |
||
1636 | xml.writeTag(WebMapContextTags.ONLINE_RESOURCE, xmlAttrs); |
||
1637 | 4730 | jaume | xmlAttrs.clear(); |
1638 | // </OnlineResource>
|
||
1639 | 6050 | jaume | |
1640 | 4730 | jaume | xml.closeTag(); |
1641 | // </Server>
|
||
1642 | 6050 | jaume | |
1643 | 4730 | jaume | // <Name>
|
1644 | 4915 | jaume | xml.writeTag(WebMapContextTags.NAME, layer.getName().trim()); |
1645 | 4730 | jaume | // </Name>
|
1646 | 6050 | jaume | |
1647 | 4730 | jaume | // <Title>
|
1648 | 8765 | jjdelcerro | xml.writeTag(WebMapContextTags.TITLE, layer.getTitle().trim()); |
1649 | //?xml.writeTag(WebMapContextTags.TITLE, getName().trim());
|
||
1650 | 4730 | jaume | // </Title>
|
1651 | 6050 | jaume | |
1652 | 4730 | jaume | // <Abstract>
|
1653 | 4915 | jaume | if (layer.getAbstract() != null) |
1654 | xml.writeTag(WebMapContextTags.ABSTRACT, layer.getAbstract()); |
||
1655 | 4730 | jaume | // </Abstract>
|
1656 | 6050 | jaume | |
1657 | 4730 | jaume | // <SRS> (a list of available SRS for the enclosing layer)
|
1658 | String[] strings = (String[]) layer.getAllSrs().toArray(new String[0]); |
||
1659 | String mySRS = strings[0]; |
||
1660 | for (int j = 1; j < strings.length; j++) { |
||
1661 | mySRS += ","+strings[j];
|
||
1662 | } |
||
1663 | 4915 | jaume | xml.writeTag(WebMapContextTags.SRS, mySRS); |
1664 | 4730 | jaume | // </SRS>
|
1665 | 6050 | jaume | |
1666 | 4730 | jaume | // <FormatList>
|
1667 | 4876 | jaume | xml.openTag(WebMapContextTags.FORMAT_LIST); |
1668 | 4730 | jaume | strings = (String[]) drv.getFormats().toArray(new String[0]); |
1669 | for (int j = 0; j < strings.length; j++) { |
||
1670 | // <Format>
|
||
1671 | 4915 | jaume | String str = strings[j].trim();
|
1672 | if (str.equals(getFormat()))
|
||
1673 | xml.writeTag(WebMapContextTags.FORMAT, str, WebMapContextTags.CURRENT, "1");
|
||
1674 | else
|
||
1675 | xml.writeTag(WebMapContextTags.FORMAT, str); |
||
1676 | 6050 | jaume | // </Format>
|
1677 | 4730 | jaume | } |
1678 | xml.closeTag(); |
||
1679 | // </FormatList>
|
||
1680 | 6050 | jaume | |
1681 | 4730 | jaume | // <StyleList>
|
1682 | 5409 | jaume | xml.openTag(WebMapContextTags.STYLE_LIST); |
1683 | 6050 | jaume | |
1684 | 5409 | jaume | if (layer.getStyles().size()>0) { |
1685 | for (int j = 0; j < layer.getStyles().size(); j++) { |
||
1686 | // <Style>
|
||
1687 | FMapWMSStyle st = (FMapWMSStyle) layer.getStyles().get(j); |
||
1688 | 5410 | jaume | if (st.name.equals(styleNames[i]))
|
1689 | 5409 | jaume | xmlAttrs.put(WebMapContextTags.CURRENT, "1");
|
1690 | xml.openTag(WebMapContextTags.STYLE, xmlAttrs); |
||
1691 | xmlAttrs.clear(); |
||
1692 | 6050 | jaume | |
1693 | 5409 | jaume | // <Name>
|
1694 | xml.writeTag(WebMapContextTags.NAME, st.name); |
||
1695 | // </Name>
|
||
1696 | 6050 | jaume | |
1697 | 5409 | jaume | // <Title>
|
1698 | xml.writeTag(WebMapContextTags.TITLE, st.title); |
||
1699 | // </Title>
|
||
1700 | 6050 | jaume | |
1701 | 5409 | jaume | // <LegendURL width="180" format="image/gif" height="50">
|
1702 | // <OnlineResource xlink:type="simple" xlink:href="http://globe.digitalearth.gov/globe/en/icons/colorbars/NATIONAL.gif"/>
|
||
1703 | // </OnlineResource>
|
||
1704 | // </LegendURL>
|
||
1705 | xml.closeTag(); |
||
1706 | // </Style>
|
||
1707 | 6050 | jaume | |
1708 | 5409 | jaume | } |
1709 | 6050 | jaume | |
1710 | 5409 | jaume | } else {
|
1711 | // Create fake style (for compatibility issues)
|
||
1712 | xmlAttrs.put(WebMapContextTags.CURRENT, "1");
|
||
1713 | 4730 | jaume | // <Style>
|
1714 | 4876 | jaume | xml.openTag(WebMapContextTags.STYLE, xmlAttrs); |
1715 | 5409 | jaume | xmlAttrs.clear(); |
1716 | 4730 | jaume | // <Name>
|
1717 | 5409 | jaume | xml.writeTag(WebMapContextTags.NAME, "default");
|
1718 | 4730 | jaume | // </Name>
|
1719 | 6050 | jaume | |
1720 | 4730 | jaume | // <Title>
|
1721 | 5409 | jaume | xml.writeTag(WebMapContextTags.TITLE, "default");
|
1722 | 4730 | jaume | // </Title>
|
1723 | 6050 | jaume | |
1724 | 5411 | jaume | // // <LegendURL width="180" format="image/gif" height="50">
|
1725 | // xmlAttrs.put(WebMapContextTags.WIDTH, "0");
|
||
1726 | // xmlAttrs.put(WebMapContextTags.HEIGHT, "0");
|
||
1727 | // xmlAttrs.put(WebMapContextTags.FORMAT.toLowerCase(), "image/gif");
|
||
1728 | // xml.openTag(WebMapContextTags.LEGEND_URL, xmlAttrs);
|
||
1729 | // xmlAttrs.clear();
|
||
1730 | // // <OnlineResource xlink:type="simple" xlink:href="http://globe.digitalearth.gov/globe/en/icons/colorbars/NATIONAL.gif"/>
|
||
1731 | // xmlAttrs.put(WebMapContextTags.XLINK_TYPE, "simple");
|
||
1732 | // xmlAttrs.put(WebMapContextTags.XLINK_HREF, "http://globe.digitalearth.gov/globe/en/icons/colorbars/NATIONAL.gif");
|
||
1733 | // xml.writeTag(WebMapContextTags.ONLINE_RESOURCE, xmlAttrs);
|
||
1734 | // // </OnlineResource>
|
||
1735 | // // </LegendURL>
|
||
1736 | // xml.closeTag();
|
||
1737 | 5409 | jaume | // </Style>
|
1738 | 4940 | jaume | xml.closeTag(); |
1739 | 4730 | jaume | } |
1740 | // </StyleList>
|
||
1741 | 5409 | jaume | xml.closeTag(); |
1742 | 4940 | jaume | if (mapContextVersion.compareTo("1.0.0") > 0) { |
1743 | 4730 | jaume | // <DimensionList>
|
1744 | 4940 | jaume | xml.openTag(WebMapContextTags.DIMENSION_LIST); |
1745 | 4730 | jaume | // <Dimension>
|
1746 | // </Dimension>
|
||
1747 | 4940 | jaume | xml.closeTag(); |
1748 | 4730 | jaume | // </DimensionList>
|
1749 | 4917 | jaume | } |
1750 | 4730 | jaume | } else {
|
1751 | xml.writeTag("ERROR", PluginServices.getText(this, "unsupported_map_context_version")); |
||
1752 | } |
||
1753 | 4833 | jaume | // </Layer>
|
1754 | xml.closeTag(); |
||
1755 | 4730 | jaume | } |
1756 | 4915 | jaume | return xml.getXML();
|
1757 | 4730 | jaume | } |
1758 | 6050 | jaume | |
1759 | public ImageIcon getTocImageIcon() { |
||
1760 | 5763 | jmvivo | return new ImageIcon(PluginServices.getPluginServices("com.iver.cit.gvsig.wms").getClassLoader().getResource("images/icoLayer.png")); |
1761 | } |
||
1762 | 6005 | nacho | |
1763 | /*
|
||
1764 | * (non-Javadoc)
|
||
1765 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getTileSize()
|
||
1766 | */
|
||
1767 | public int[] getTileSize() { |
||
1768 | 6050 | jaume | int[] size = {maxTileDrawWidth, maxTileDrawHeight}; |
1769 | 6005 | nacho | return size;
|
1770 | } |
||
1771 | |||
1772 | /*
|
||
1773 | * (non-Javadoc)
|
||
1774 | * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#isTiled()
|
||
1775 | */
|
||
1776 | public boolean isTiled() { |
||
1777 | return mustTileDraw;
|
||
1778 | } |
||
1779 | 6050 | jaume | |
1780 | 8765 | jjdelcerro | public Image getImageLegend() { |
1781 | try {
|
||
1782 | if (wms.hasLegendGraphic() ){
|
||
1783 | wmsStatus.setOnlineResource((String) onlineResources.get("GetLegendGraphic")); |
||
1784 | File legend = getDriver().getLegendGraphic(wmsStatus, layerQuery, null); |
||
1785 | Image img = null; |
||
1786 | if ((legend!= null) && (legend.length() > 0)) |
||
1787 | img = ImageIO.read(legend);
|
||
1788 | return img;
|
||
1789 | }else{
|
||
1790 | return null; |
||
1791 | } |
||
1792 | }catch(Exception e){ |
||
1793 | 9056 | nacho | //e.printStackTrace();
|
1794 | 8765 | jjdelcerro | return null; |
1795 | } |
||
1796 | } |
||
1797 | 6050 | jaume | |
1798 | 9056 | nacho | /**
|
1799 | * Obtiene el grid asociado al raster que hay cargado en ese momento
|
||
1800 | * @return grid
|
||
1801 | */
|
||
1802 | public Grid getGrid(){
|
||
1803 | return grid;
|
||
1804 | } |
||
1805 | |||
1806 | /**
|
||
1807 | * Obtiene el tipo de dato de la capa raster
|
||
1808 | * @return Entero que representa el tipo de dato de la capa raster.
|
||
1809 | */
|
||
1810 | public int getDataType() { |
||
1811 | return rasterFile.getDataType();
|
||
1812 | } |
||
1813 | 10362 | ldiaz | public boolean isQueryable(){ |
1814 | return queryable;
|
||
1815 | } |
||
1816 | 3746 | jaume | } |