svn-gvsig-desktop / branches / gvSIG_WMSv2 / extensions / extWMS / src / com / iver / cit / gvsig / gui / wizards / WMSWizardData.java @ 3524
History | View | Annotate | Download (4.42 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.gui.wizards; |
42 |
|
43 |
import java.awt.geom.Rectangle2D; |
44 |
import java.net.URL; |
45 |
import java.util.ArrayList; |
46 |
import java.util.Vector; |
47 |
|
48 |
import com.iver.andami.PluginServices; |
49 |
import com.iver.cit.gvsig.fmap.DriverException; |
50 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
51 |
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode; |
52 |
|
53 |
|
54 |
/**
|
55 |
* DOCUMENT ME!
|
56 |
*
|
57 |
* @author Fernando Gonz?lez Cort?s
|
58 |
*/
|
59 |
public class WMSWizardData implements WizardData { |
60 |
private String title; |
61 |
private String theAbstract; |
62 |
private WMSLayerNode layer;
|
63 |
private String[] formats; |
64 |
private String serverVersion; |
65 |
private FMapWMSDriver wms = null; |
66 |
|
67 |
|
68 |
/**
|
69 |
* @return Returns the serverVersion.
|
70 |
*/
|
71 |
public String getServerVersion() { |
72 |
return serverVersion;
|
73 |
} |
74 |
public String getHost(){ |
75 |
return wms.getHost();
|
76 |
} |
77 |
|
78 |
public void setHost(URL host) throws DriverException{ |
79 |
wms = new FMapWMSDriver();
|
80 |
wms.createClient(host); |
81 |
// Send a getCapabilities request;
|
82 |
if (!wms.connect())
|
83 |
throw new DriverException(PluginServices.getText(this, "imposible_conectar"+host.toString())); |
84 |
|
85 |
title = wms.getServiceTitle(); |
86 |
|
87 |
if (wms.getAbstract() != null) |
88 |
theAbstract = wms.getAbstract(); |
89 |
|
90 |
|
91 |
|
92 |
Vector f = wms.getFormats();
|
93 |
ArrayList formatos = new ArrayList(); |
94 |
for (int i = 0; i < f.size(); i++) { |
95 |
if (isValidFormat((String)f.elementAt(i))) { |
96 |
formatos.add(f.elementAt(i)); |
97 |
} |
98 |
} |
99 |
formats = (String[]) formatos.toArray(new String[0]); |
100 |
serverVersion = wms.getVersion(); |
101 |
WMSLayerNode root = wms.getLayersTree(); // LayersTree as they are defined in the Capabilities document
|
102 |
|
103 |
layer = root; |
104 |
} |
105 |
|
106 |
/**
|
107 |
* M?todo para saber los formatos que admite la aplicaci?n
|
108 |
*
|
109 |
* @param format cadena con el formato a validar
|
110 |
*
|
111 |
* @return true si soportamos dicho formato y false en
|
112 |
* caso contrario
|
113 |
*/
|
114 |
private boolean isValidFormat(String format) { |
115 |
if (format.equalsIgnoreCase("image/png") || |
116 |
format.equalsIgnoreCase("image/jpg") ||
|
117 |
format.equalsIgnoreCase("image/tiff") ||
|
118 |
format.equalsIgnoreCase("image/jpeg") ||
|
119 |
format.equalsIgnoreCase("image/tif") ||
|
120 |
format.equalsIgnoreCase("image/gif")) {
|
121 |
return true; |
122 |
} |
123 |
|
124 |
return false; |
125 |
} |
126 |
/**
|
127 |
* DOCUMENT ME!
|
128 |
*
|
129 |
* @return
|
130 |
*/
|
131 |
public String getAbstract() { |
132 |
return theAbstract;
|
133 |
} |
134 |
|
135 |
/**
|
136 |
* DOCUMENT ME!
|
137 |
*
|
138 |
* @return
|
139 |
*/
|
140 |
public String[] getFormats() { |
141 |
return formats;
|
142 |
} |
143 |
|
144 |
/**
|
145 |
* DOCUMENT ME!
|
146 |
*
|
147 |
* @return
|
148 |
*/
|
149 |
public WMSLayerNode getLayer() {
|
150 |
return layer;
|
151 |
} |
152 |
|
153 |
/**
|
154 |
* DOCUMENT ME!
|
155 |
*
|
156 |
* @return
|
157 |
*/
|
158 |
public String getTitle() { |
159 |
return title;
|
160 |
} |
161 |
|
162 |
|
163 |
|
164 |
/**
|
165 |
* @return Returns the serverType.
|
166 |
*/
|
167 |
public String getServerType() { |
168 |
return "WMS "+serverVersion; |
169 |
} |
170 |
|
171 |
|
172 |
|
173 |
public Rectangle2D getBoundingBox(String[] layerNames, String srs) { |
174 |
return wms.getLayersExtent(layerNames, srs);
|
175 |
} |
176 |
} |