svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / fmap / layers / FLyrWCS.java @ 2420
History | View | Annotate | Download (19.7 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
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 |
* Av. Blasco Ib??ez, 50
|
24 |
* 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 |
import java.awt.Graphics2D; |
45 |
import java.awt.geom.Point2D; |
46 |
import java.awt.geom.Rectangle2D; |
47 |
import java.awt.image.BufferedImage; |
48 |
import java.io.IOException; |
49 |
import java.net.URL; |
50 |
import java.util.TreeMap; |
51 |
|
52 |
import javax.swing.JOptionPane; |
53 |
|
54 |
import com.iver.andami.PluginServices; |
55 |
import com.iver.cit.gvsig.fmap.DriverException; |
56 |
import com.iver.cit.gvsig.fmap.ViewPort; |
57 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
58 |
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver; |
59 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
60 |
import com.iver.cit.gvsig.fmap.services.OGCWCSService; |
61 |
import com.iver.cit.gvsig.gui.View; |
62 |
import com.iver.cit.gvsig.gui.WCSDataSourceAdapter; |
63 |
import com.iver.cit.gvsig.gui.Panels.WCSParamsPanel; |
64 |
import com.iver.cit.gvsig.gui.wcs.WCSWizardData; |
65 |
import com.iver.cit.gvsig.gui.wcs.WCSWizardDataSource; |
66 |
import com.iver.utiles.StringUtilities; |
67 |
import com.iver.utiles.XMLEntity; |
68 |
|
69 |
import es.uji.lsi.wcs.client.ServerErrorResponseException; |
70 |
|
71 |
/**
|
72 |
* Class for the WCS layer.
|
73 |
*
|
74 |
* Capa para el WCS.
|
75 |
*
|
76 |
* @author jaume - jaume.dominguez@iver.es
|
77 |
*/
|
78 |
public class FLyrWCS extends FLyrDefault { |
79 |
private FMapWCSAdaptor wcs = null; |
80 |
|
81 |
private String label; |
82 |
private WCSParamsPanel toc = null; |
83 |
|
84 |
|
85 |
/**
|
86 |
* Returns the XMLEntity containing the necessary info for reproduce
|
87 |
* the layer.
|
88 |
*
|
89 |
* Devuelve el XMLEntity con la informaci?n necesaria para reproducir
|
90 |
* la capa.
|
91 |
*
|
92 |
* @return XMLEntity.
|
93 |
* @throws XMLException
|
94 |
*/
|
95 |
public XMLEntity getXMLEntity() throws XMLException { |
96 |
XMLEntity xml = super.getXMLEntity();
|
97 |
|
98 |
xml.putProperty("wcs.host", getHost());
|
99 |
try {
|
100 |
xml.putProperty("wcs.fullExtent",
|
101 |
StringUtilities.rect2String(wcs.getFullExtent())); |
102 |
} catch (IOException e) { |
103 |
} catch (DriverException e) {
|
104 |
} |
105 |
xml.putProperty("wcs.layerQuery", wcs.getCoverageQuery());
|
106 |
xml.putProperty("wcs.format", getFormat());
|
107 |
xml.putProperty("wcs.srs", getSRS());
|
108 |
xml.putProperty("wcs.time", getTime());
|
109 |
xml.putProperty("wcs.parameter", getParameter());
|
110 |
xml.putProperty("wcs.label", label);
|
111 |
xml.putProperty("wcs.coverageName", getCoverageName());
|
112 |
xml.putProperty("wcs.maxResX", getMaxResolution().getX());
|
113 |
xml.putProperty("wcs.maxResY", getMaxResolution().getY());
|
114 |
return xml;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Reproduces the layer from an XMLEntity.
|
119 |
*
|
120 |
* A partir del XMLEntity reproduce la capa.
|
121 |
*
|
122 |
* @param xml XMLEntity
|
123 |
*
|
124 |
* @throws XMLException
|
125 |
* @throws DriverException
|
126 |
* @throws DriverIOException
|
127 |
*/
|
128 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
129 |
super.setXMLEntity(xml);
|
130 |
//System.out.println(" Cargo la capa WCS. ... o no ;-)");
|
131 |
setHost(xml.getStringProperty("wcs.host"));
|
132 |
setFullExtent(StringUtilities.string2Rect( |
133 |
xml.getStringProperty("wcs.fullExtent")));
|
134 |
wcs.setCoverageQuery(xml.getStringProperty("wcs.layerQuery"));
|
135 |
setFormat(xml.getStringProperty("wcs.format"));
|
136 |
setSRS(xml.getStringProperty("wcs.srs"));
|
137 |
setTime(xml.getStringProperty("wcs.time"));
|
138 |
setParameter(xml.getStringProperty("wcs.parameter"));
|
139 |
label = xml.getStringProperty("wcs.label");
|
140 |
setCoverageName(xml.getStringProperty("wcs.coverageName"));
|
141 |
if (xml.contains("wcs.maxRes")) |
142 |
setMaxResolution(new Point2D.Double(xml.getDoubleProperty("wcs.maxRes"), xml.getDoubleProperty("wcs.maxRes"))); |
143 |
else if (xml.contains("wcs.maxResX") && xml.contains("wcs.maxResY")) |
144 |
setMaxResolution(new Point2D.Double(xml.getDoubleProperty("wcs.maxResX"), xml.getDoubleProperty("wcs.maxResY"))); |
145 |
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* The full extent of the layer.
|
150 |
*
|
151 |
* La extensi?n completa de la layer.
|
152 |
*
|
153 |
* @return Rectangle2D
|
154 |
*/
|
155 |
public Rectangle2D getFullExtent(){// throws DriverException { |
156 |
try {
|
157 |
return getWCSAdaptor().getFullExtent();
|
158 |
} catch (IOException e) { |
159 |
JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE); |
160 |
} catch (DriverException e) {
|
161 |
JOptionPane.showMessageDialog(null, "servidor_wcs_no_responde", "Error", JOptionPane.ERROR_MESSAGE); |
162 |
} |
163 |
return null; |
164 |
} |
165 |
|
166 |
/**
|
167 |
* Draws the layer on the ViewPort using PxRaster.
|
168 |
*
|
169 |
* Dibuja la capa en el ViewPort con PxRaster.
|
170 |
*/
|
171 |
public synchronized void draw(BufferedImage image, Graphics2D g, |
172 |
ViewPort viewPort, Cancellable cancel) throws DriverException {
|
173 |
/* This try loop I've moved here is for show an alert window when it is not
|
174 |
* possible to download the coverage.
|
175 |
*/
|
176 |
try {
|
177 |
wcs.draw(image, g, viewPort, cancel); |
178 |
} catch (ServerErrorResponseException e) {
|
179 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage(), "Error", |
180 |
JOptionPane.ERROR_MESSAGE);
|
181 |
// View view=(View)PluginServices.getMDIManager().getActiveView();
|
182 |
// view.getTOC().layerRemoved(LayerCollectionEvent.createLayerRemovedEvent(this));
|
183 |
} |
184 |
} |
185 |
/**
|
186 |
* Prints the layer.
|
187 |
*
|
188 |
* Imprime la cobertura.
|
189 |
*/
|
190 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel) |
191 |
throws DriverException {
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* Sets the layer's label. That what is going to be used at the TOC.
|
196 |
*
|
197 |
* Establece la etiqueta de la cobertura. La que se usar? en el TOC.
|
198 |
*
|
199 |
* @param lbl
|
200 |
*/
|
201 |
public void setLabel(String lbl) { |
202 |
label = lbl; |
203 |
} |
204 |
|
205 |
/**
|
206 |
* Sets the layer's full extent.
|
207 |
*
|
208 |
* Establece la extensi?n m?xima de la capa.
|
209 |
*
|
210 |
* @param rect
|
211 |
*/
|
212 |
public void setFullExtent(Rectangle2D rect) { |
213 |
wcs.setFullExtent(rect); |
214 |
} |
215 |
|
216 |
/**
|
217 |
* Recovers the name of the layer shown on the TOC. The text used for the name
|
218 |
* is not the actual coverage's name but that what appears in the wizard's text
|
219 |
* field which initially correponds with the "label" specified by the server for
|
220 |
* the coverage and may be edited by the user for choose whatever she/he wants.
|
221 |
*
|
222 |
* Recupera el nom de la capa mostrada al TOC. El text per al nom no ?s el
|
223 |
* nom de la covertura sin? el text que apareix al camp de text del wizard,
|
224 |
* que es correspon amb la "label" que el servidor especifica per a la
|
225 |
* covertura, i pot ser modificat per l'usuari al wizard per a gastar el que
|
226 |
* dessitge.
|
227 |
*
|
228 |
* @return String
|
229 |
*/
|
230 |
public String getLabel() { |
231 |
return this.label; |
232 |
} |
233 |
|
234 |
/**
|
235 |
* Sets TabbedPane shown when WCS_Properties is clicked within the TOC.
|
236 |
*
|
237 |
* Establece el TabbedPane mostrado cuando se clica en WCS_Properties dentro del TOC.
|
238 |
*
|
239 |
* @param panel
|
240 |
*/
|
241 |
public void setToc(WCSParamsPanel panel) { |
242 |
toc = panel; |
243 |
} |
244 |
|
245 |
/**
|
246 |
* With getParamsPanel we have acces to the coverage config TabbedPane.
|
247 |
* If this panel doesn't exist yet (which can occur when an existing project is
|
248 |
* recovered) it is been automatically constructed by connecting to the server,
|
249 |
* reloading the necessary data, filling up the content and setting the selected
|
250 |
* values that were selected when the projet was saved.
|
251 |
*
|
252 |
* Since a connection to the server is needed when rebuiliding the panel, this
|
253 |
* causes a delay for the panel's showing up or a nullPointer error if there is
|
254 |
* no path to the server.
|
255 |
*
|
256 |
*
|
257 |
* Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n
|
258 |
* de la cobertura. Si este panel todav?a no existe (como puede ser cuando
|
259 |
* recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando
|
260 |
* al servidor, recuperando los datos necesarios, rellenando el contenido y
|
261 |
* dejando seleccionados los valores que estaban seleccionados cuando se
|
262 |
* guard? el proyecto.
|
263 |
*
|
264 |
* Como para reconstruirse requiere una conexi?n con el servidor esto causa
|
265 |
* un retardo en la aparici?n en el toc o un error de nullPointer si no
|
266 |
* hay conexi?n hasta el servidor.
|
267 |
*
|
268 |
* @return WCSParamsPanel
|
269 |
*/
|
270 |
public WCSParamsPanel getParamsPanel() {
|
271 |
if (toc == null) { |
272 |
try {
|
273 |
WCSWizardDataSource dataSource = new WCSDataSourceAdapter();
|
274 |
WCSWizardData data = dataSource.detalles( new URL(getHost()) ); |
275 |
|
276 |
toc = new WCSParamsPanel();
|
277 |
|
278 |
|
279 |
toc.setWizardData(data); |
280 |
toc.setDataSource(dataSource); |
281 |
|
282 |
toc.getLstCoverages().setListData(data.getCoverageNames()); |
283 |
|
284 |
int index = toc.getCoverageIndex(wcs.getCoverageName());
|
285 |
if (index != -1) |
286 |
toc.getLstCoverages().setSelectedIndex(index); |
287 |
|
288 |
toc.actualizaWizard(); |
289 |
|
290 |
index = toc.getSRSIndex(wcs.getSRS()); |
291 |
if (index != -1) |
292 |
toc.getLstCRSs().setSelectedIndex(index); |
293 |
index = toc.getFormatIndex(wcs.getFormat()); |
294 |
if (index != -1) |
295 |
toc.getLstFormats().setSelectedIndex(index); |
296 |
if (wcs.getTime() != null) |
297 |
toc.getLstSelectedTimes().setListData(wcs.getTime().split("=")[1].split(",")); |
298 |
/* vale, i ara.. per al cas d'intervals continus? se m'ocorre
|
299 |
* fer un text field. Per? aix? ja vindr? si ha de vindre.
|
300 |
*/
|
301 |
if (wcs.getParameter()!= null){ |
302 |
String[] s = wcs.getParameter().split("="); |
303 |
String pName = s[0]; |
304 |
String[] pVals = s[1].split(","); |
305 |
index = toc.getParamIndex(pName); |
306 |
toc.getCmbParam().setSelectedIndex(index); |
307 |
toc.actualizaListaParametros(wcs.getCoverageName()); |
308 |
int[] indexes = new int[pVals.length]; |
309 |
for (int i = 0; i < pVals.length; i++) { |
310 |
indexes[i] = toc.getValueIndex(pVals[i]); |
311 |
} |
312 |
/* vale, i ara.. per al cas d'intervals continus? se m'ocorre
|
313 |
* fer un text field. Per? aix? ja vindr? si ha de vindre.
|
314 |
*/
|
315 |
|
316 |
toc.getLstParamValues().setSelectedIndices(indexes); |
317 |
} |
318 |
} catch (DriverException soe) {
|
319 |
JOptionPane.showMessageDialog(null, "servidor_wcs_no_responde", "Error", JOptionPane.ERROR_MESSAGE); |
320 |
} catch (IOException ioe){ |
321 |
JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE); |
322 |
} catch (Exception e) { |
323 |
e.printStackTrace(); |
324 |
} |
325 |
} |
326 |
return toc;
|
327 |
} |
328 |
|
329 |
/**
|
330 |
* Returns the coverage name.
|
331 |
*
|
332 |
* Obtiene el nombre de la cobertura.
|
333 |
* @return String
|
334 |
*/
|
335 |
public String getCoverageName() { |
336 |
return wcs.getCoverageName();
|
337 |
} |
338 |
|
339 |
/**
|
340 |
* Returns the coverage format.
|
341 |
*
|
342 |
* Obtiene el formato en que la cobertura est? codificado.
|
343 |
* @return String
|
344 |
*/
|
345 |
public String getFormat() { |
346 |
return wcs.getFormat();
|
347 |
} |
348 |
|
349 |
/**
|
350 |
* Returns the WCS server URL.
|
351 |
*
|
352 |
* Obtiene la direcci?n URL del servidor WCS
|
353 |
*
|
354 |
* @return String
|
355 |
*/
|
356 |
public String getHost() { |
357 |
return wcs.getHost();
|
358 |
} |
359 |
|
360 |
/**
|
361 |
* Returns the parameter value.
|
362 |
*
|
363 |
* Obtiene el valor del par?metro.
|
364 |
* @return String
|
365 |
*/
|
366 |
public String getParameter() { |
367 |
return wcs.getParameter();
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* Returns the current SRS.
|
372 |
*
|
373 |
* Obtiene el SRS actual de la cobertura.
|
374 |
* @return String
|
375 |
*/
|
376 |
public String getSRS() { |
377 |
return wcs.getSRS();
|
378 |
} |
379 |
|
380 |
/**
|
381 |
* Returns the TIME value in the WCS query.
|
382 |
*
|
383 |
* Obtiene el valor para TIME en la consulta WCS.
|
384 |
* @return String
|
385 |
*/
|
386 |
public String getTime() { |
387 |
return wcs.getTime();
|
388 |
} |
389 |
|
390 |
/**
|
391 |
* Sets the FORMAT parameter that we are requesting the WCS coverage.
|
392 |
*
|
393 |
* Establece el par?metro FORMAT en que se pide la cobertura WCS
|
394 |
* @param format
|
395 |
*/
|
396 |
public void setFormat(String format) { |
397 |
wcs.setFormat(format); |
398 |
} |
399 |
|
400 |
/**
|
401 |
* Sets the server's URL.
|
402 |
*
|
403 |
* Establece la direcci?n URL del servidor WCS
|
404 |
* @param host
|
405 |
*/
|
406 |
public void setHost(String host) { |
407 |
if (wcs == null) { |
408 |
wcs = new FMapWCSAdaptor();
|
409 |
wcs.setDriver(new FMapWCSDriver());
|
410 |
} |
411 |
wcs.setHost(host); |
412 |
} |
413 |
|
414 |
/**
|
415 |
* Sets the parameter. It is defined by a name-value pair and the value is
|
416 |
* a comma-separated list of values.
|
417 |
*
|
418 |
* Establece el nombre y el valor (lista de valores separados por comas)
|
419 |
* del par?metro de la consulta WCS
|
420 |
* @param parameter
|
421 |
*/
|
422 |
public void setParameter(String parameter) { |
423 |
wcs.setParameter(parameter); |
424 |
} |
425 |
|
426 |
/**
|
427 |
* Sets the SRS parameter within the WCS query.
|
428 |
*
|
429 |
* Establece el SRS de la consulta WCS.
|
430 |
* @param srs
|
431 |
*/
|
432 |
public void setSRS(String srs) { |
433 |
wcs.setSRS(srs); |
434 |
} |
435 |
|
436 |
/**
|
437 |
* Sets the TIME parameter within the WCS query.
|
438 |
*
|
439 |
* Establece el par?metro TIME de la consulta WCS.
|
440 |
* @param time
|
441 |
*/
|
442 |
public void setTime(String time) { |
443 |
/*if (time.matches("TIME=*"))
|
444 |
wcs.setTime(time.split("=")[1]);
|
445 |
else*/
|
446 |
wcs.setTime(time); |
447 |
} |
448 |
|
449 |
/**
|
450 |
* Sets the COVERAGE parameter within the WCS query.
|
451 |
*
|
452 |
* Establece el par?metro COVERAGE de la consulta WCS.
|
453 |
* @param coverageName
|
454 |
*/
|
455 |
public void setCoverageName(String coverageName) { |
456 |
wcs.setCoverageName(coverageName); |
457 |
} |
458 |
|
459 |
/**
|
460 |
* Gets the max resolution allowed by the coverage. Requesting a higher resolution
|
461 |
* than this value does not cause any error, but the info responsed is just an
|
462 |
* interpolation.
|
463 |
*
|
464 |
* In exchange for obtaining a greater file and without additional information,
|
465 |
* we can easily connect it at the View.
|
466 |
*
|
467 |
*
|
468 |
* Obtiene la resoluci?n m?xima soportada por la cobertura. La petici?n
|
469 |
* de una resoluci?n superior a la soportada no provoca ning?n error, aunque
|
470 |
* la informaci?n obtenida s?lo es una mera interpolaci?n de informaci?n.
|
471 |
*
|
472 |
* A cambio de obtener un archivo mayor y sin informaci?n adicional, podemos
|
473 |
* f?cilmente acoplarlo a la vista.
|
474 |
*
|
475 |
* @return double
|
476 |
*/
|
477 |
//public double getMaxResolution(){
|
478 |
public Point2D getMaxResolution() { |
479 |
return wcs.getMaxResolution();
|
480 |
} |
481 |
|
482 |
/**
|
483 |
* Sets the MAX resolution supported by the coverage.
|
484 |
*
|
485 |
* The max resolution is given by the server within the DescribeCoverage document
|
486 |
* in the SpationDomain section.
|
487 |
*
|
488 |
* Use this method only to load this value from there (the DescribeCoverage document)
|
489 |
* of from an already saved project because an incorrect value will bring
|
490 |
* computing errors when doing "zoom to raster resolution".
|
491 |
*
|
492 |
*
|
493 |
*
|
494 |
* Establece la resoluci?n M?XIMA que soporta la cobertura.
|
495 |
*
|
496 |
* La resoluci?n m?xima viene fijada por el servidor dentro documento
|
497 |
* DescribeCoverage en la secci?n SpatialDomain.
|
498 |
*
|
499 |
* Use este m?todo ?nicamente para cargar el valor para la resoluci?n m?xima
|
500 |
* desde all? o desde un proyecto guardado en anterioridad, puesto que un
|
501 |
* valor incorrecto reportar? (conllevar?) errores de c?lculo cuando se haga
|
502 |
* un "zoom a la resoluci?n del r?ster".
|
503 |
*
|
504 |
* @param res
|
505 |
*/
|
506 |
//public void setMaxResolution(double res){
|
507 |
public void setMaxResolution(Point2D res){ |
508 |
wcs.setMaxResolution(res); |
509 |
} |
510 |
|
511 |
/**
|
512 |
* Returns the adaptor.
|
513 |
*
|
514 |
* Obtiene el adaptor.
|
515 |
*/
|
516 |
public FMapWCSAdaptor getWCSAdaptor(){
|
517 |
return wcs;
|
518 |
} |
519 |
|
520 |
/**
|
521 |
* Sets the adaptor.
|
522 |
*
|
523 |
* Establece el adaptador.
|
524 |
*
|
525 |
* @deprecated
|
526 |
* @param wcs
|
527 |
*/
|
528 |
public void setWCSAdaptor(FMapWCSAdaptor wcs){ |
529 |
this.wcs = wcs;
|
530 |
} |
531 |
|
532 |
/**
|
533 |
* Returns the bounding box that is being used.
|
534 |
*
|
535 |
* Obtiene la Bounding Box sobre la que se est? operando
|
536 |
* @return Rectangle2D
|
537 |
*/
|
538 |
private Rectangle2D getBbox() { |
539 |
return wcs.getBbox();
|
540 |
} |
541 |
|
542 |
/**
|
543 |
* Returns the current resolution for the coverage at the view.
|
544 |
*
|
545 |
* Obtiene la resoluci?n actual para la cobertura de la vista.
|
546 |
* @return
|
547 |
*/
|
548 |
//private double getRes() {
|
549 |
private Point2D getRes() { |
550 |
return wcs.getRes();
|
551 |
} |
552 |
|
553 |
/**
|
554 |
* Sets the current resolution for the coverage at the view.
|
555 |
* This value is automatically calculated by gvSIG. Thus, this method should
|
556 |
* be used only to reload this value from a previously saved project.
|
557 |
*
|
558 |
* Establece la resoluci?n actual para la cobertura de la vista.
|
559 |
* Este valor es calculado autom?ticamente por gvSIG. ?ste m?todo deber?a
|
560 |
* ser usado ?nicamente para recuperar este valor de un proyecto
|
561 |
* anteriormente guardado.
|
562 |
* @param res
|
563 |
*/
|
564 |
//private void setRes(double res) {
|
565 |
private void setRes(Point2D res) { |
566 |
wcs.setRes(res); |
567 |
} |
568 |
|
569 |
/**
|
570 |
* Sets the area of the coverage to request.
|
571 |
* This value is automatically calculated by gvSIG. Thus, this method should
|
572 |
* be used only to reload this value from a previuosly saved project.
|
573 |
*
|
574 |
* Establece el ?rea de la cobertura a pedir.
|
575 |
* Este valor es calculado autom?ticamente por gvSIG. ?ste m?todo deber?a
|
576 |
* ser usado ?nicamente para recuperar el valor de un proyecto anteriormente
|
577 |
* guardado.
|
578 |
*
|
579 |
* @param rect
|
580 |
*/
|
581 |
private void setBBox(Rectangle2D rect) { |
582 |
wcs.setBBox(rect); |
583 |
} |
584 |
|
585 |
/**
|
586 |
* Builds a coverage starting from a full GetCoverage URL.
|
587 |
* (Using this is not a regular function)
|
588 |
*
|
589 |
* Inicializa una cobertura a partir de una URL GetCoverage completa.
|
590 |
* (To use this method supposes to skip all the regular operation)
|
591 |
*
|
592 |
*/
|
593 |
public void initFromQueryString(String queryString){ |
594 |
System.out.println("Query = "+queryString); |
595 |
TreeMap map = new TreeMap(); |
596 |
String[] params = queryString.split("&"); |
597 |
for (int i = 0; i < params.length; i++) { |
598 |
String[] nameValue = params[i].split("="); |
599 |
map.put(nameValue[0].toUpperCase(), nameValue[1]); |
600 |
} |
601 |
try {
|
602 |
String coverageName = (String) map.get((String) "COVERAGE"); |
603 |
String crs = (String) map.get((String) "CRS"); |
604 |
String format = (String) map.get((String) "FORMAT"); |
605 |
String time = (String) map.get((String) "TIME"); |
606 |
String bands = (String) map.get((String) "BANDS"); |
607 |
|
608 |
setSRS(crs); |
609 |
setCoverageName(coverageName); |
610 |
if (time != null) |
611 |
setTime("TIME="+time);
|
612 |
OGCWCSService service = (OGCWCSService) wcs.getDriver(); |
613 |
service.connect(); |
614 |
|
615 |
setLabel( service.getLabel(coverageName) ); |
616 |
setName( getLabel() ); |
617 |
setFullExtent ( service.getFullExtent(coverageName, crs) ); |
618 |
setFormat( format ); |
619 |
setParameter( "BANDS="+bands );
|
620 |
setMaxResolution ( service.getMaxResolution(coverageName) ); |
621 |
|
622 |
} catch (IOException e) { |
623 |
e.printStackTrace(); |
624 |
} catch (DriverException e) {
|
625 |
e.printStackTrace(); |
626 |
} |
627 |
} |
628 |
|
629 |
/**
|
630 |
* Builds a coverage starting from a full GetCoverage URL.
|
631 |
* (Using this is not a regular function)
|
632 |
*
|
633 |
* Inicializa una cobertura a partir de una URL GetCoverage completa.
|
634 |
* (Usar este m?todo supone saltarse todo el funcionamiento normal)
|
635 |
*
|
636 |
* TODO Por completar y probar
|
637 |
* @param queryString
|
638 |
*/
|
639 |
public void initFromQueryString2(String queryString){ |
640 |
|
641 |
String host = queryString.substring(0, queryString.indexOf('?')); |
642 |
String[] params = queryString.substring(queryString.indexOf('?')+1, queryString.length()).split("="); |
643 |
setHost(host); |
644 |
for (int i = 0; i < params.length; i++) { |
645 |
String[] par_nombreValor = params[i].split("="); |
646 |
String nombre = par_nombreValor[0].toUpperCase(); |
647 |
String valor = par_nombreValor[1]; |
648 |
if (nombre.equals("COVERAGE")) setCoverageName(valor); |
649 |
else if (nombre.equals("TIME")) setTime(valor); |
650 |
else if (nombre.equals("FORMAT")) setFormat(valor); |
651 |
else if (nombre.equals("CRS")) setSRS(valor); |
652 |
else if (nombre.equals("EXCEPTIONS")) continue; |
653 |
else if (nombre.equals("RESX")) continue; |
654 |
else if (nombre.equals("RESY")) continue; |
655 |
else if (nombre.equals("RESZ")) continue; |
656 |
else if (nombre.equals("WIDTH")) continue; |
657 |
else if (nombre.equals("HEIGHT")) continue; |
658 |
else if (nombre.equals("DEPTH")) continue; |
659 |
else if (nombre.equals("BBOX")) continue; |
660 |
else if (nombre.equals("RESPONSE_CRS")) continue; |
661 |
else setParameter(nombre+"="+valor); |
662 |
} |
663 |
} |
664 |
} |