root / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / WMSClient.java @ 2992
History | View | Annotate | Download (4.79 KB)
1 | 2991 | ldiaz | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 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 org.gvsig.remoteClient; |
||
42 | |||
43 | import java.io.IOException; |
||
44 | import java.util.ArrayList; |
||
45 | |||
46 | import org.gvsig.remoteClient.driver.RemoteServiceDriver; |
||
47 | import org.gvsig.remoteClient.driver.wms.WMSDriver; |
||
48 | import org.gvsig.remoteClient.exception.ServerOutOfOrderException; |
||
49 | import org.gvsig.remoteClient.exception.UnsupportedVersionException; |
||
50 | import org.gvsig.remoteClient.exception.WMSException; |
||
51 | import com.iver.cit.gvsig.fmap.DriverException; |
||
52 | |||
53 | /**
|
||
54 | * Class that describes a Client interface to a OGC Web Mapping Service
|
||
55 | * @author Jaume
|
||
56 | * @author Laura Diaz
|
||
57 | */
|
||
58 | public class WMSClient extends RemoteServiceDriver implements ServiceClient |
||
59 | { |
||
60 | WMSDriver wms; |
||
61 | |||
62 | public String getName() { return "WMSDriver"; } |
||
63 | |||
64 | /**
|
||
65 | * Sets the server that we want to connect to.
|
||
66 | * Establece el servidor al que se quiere conectar.
|
||
67 | * @param host
|
||
68 | */
|
||
69 | public void setHost(String host){ |
||
70 | super.setHost(host);
|
||
71 | setServiceName("WMS");
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * Sends the GetCapabilities operation to the server.
|
||
76 | * Env?a la operaci?n GetCapabilities al servidor.
|
||
77 | * @throws ServerOutOfOrderException
|
||
78 | */
|
||
79 | public void getCapabilities() |
||
80 | throws ServerOutOfOrderException, IOException, UnsupportedVersionException { |
||
81 | wms.getCapabilities(); |
||
82 | } |
||
83 | |||
84 | public void getMap() |
||
85 | throws IOException, NoSuchFieldException, WMSException { |
||
86 | wms.getMap(); |
||
87 | } |
||
88 | |||
89 | public void getFeatureInfo() |
||
90 | throws IOException, NoSuchFieldException, WMSException { |
||
91 | wms.getFeatureInfo(); |
||
92 | } |
||
93 | |||
94 | /**
|
||
95 | * Returns the server's name. The string is extracted from the GetCapabilities
|
||
96 | * response.
|
||
97 | * Devuelve el nombre del servidor indicado por ?ste.
|
||
98 | * @return String
|
||
99 | */
|
||
100 | public String getServerName(){ |
||
101 | return ""; |
||
102 | } |
||
103 | |||
104 | /**
|
||
105 | * Returns a string containing the server's WMS version number.
|
||
106 | * Devuelve el n?mero de versi?n WMS del servidor
|
||
107 | * @return String
|
||
108 | */
|
||
109 | public String getVersion(){ |
||
110 | return ""; //wms.getCapabilities().getVersion; |
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * Returns name and description of the server. It is supposed to be used
|
||
115 | * as the source of the abstract field in your application's interface.
|
||
116 | * Devuelve nombre y descripci?n (abstract) del servidor.
|
||
117 | * @return String
|
||
118 | */
|
||
119 | public String getDescription(){ |
||
120 | String name="";//wms.getCapabilities().getServiceName(); |
||
121 | String description = ""; //wms.getCapabilities().getServiceDescription(); |
||
122 | |||
123 | if ( (name == null) && (description == null) ) return "Sin descripci?n"; |
||
124 | else if ( (name != null) && (description == null) ) return name; |
||
125 | else if ( (name == null) && (description != null) ) return description; |
||
126 | else if ( (name != null) && (description != null) ) return name+"\n\n"+description; |
||
127 | else return null; |
||
128 | } |
||
129 | |||
130 | |||
131 | /**
|
||
132 | * Returns a list containing the formats supported by the coverage
|
||
133 | * Devuelve una lista de formatos soportados por la cobertura.
|
||
134 | * @param coverage
|
||
135 | * @return ArrayList
|
||
136 | */
|
||
137 | public ArrayList getFormats(){ |
||
138 | 2992 | ldiaz | ArrayList formats = null; |
139 | try
|
||
140 | { |
||
141 | formats = wms.getCapabilities().getServiceInformation().getFormats(); |
||
142 | //return null;//wms.getCapabilities().getFormats();
|
||
143 | } |
||
144 | catch(Exception e){} |
||
145 | |||
146 | return formats;
|
||
147 | 2991 | ldiaz | } |
148 | |||
149 | public String[] getLayerNames(){ |
||
150 | 2992 | ldiaz | String[] names = null; |
151 | try
|
||
152 | { |
||
153 | names = wms.getCapabilities().getMapComposition().getLayerNames(); |
||
154 | } |
||
155 | catch(Exception e){} |
||
156 | return names;
|
||
157 | 2991 | ldiaz | } |
158 | |||
159 | /**
|
||
160 | * Returns the number of layers at the server.
|
||
161 | * Devuelve el numero de layers en el servidor
|
||
162 | * @return int
|
||
163 | */
|
||
164 | public int getNumOfLayers(){ |
||
165 | return getLayerNames().length;
|
||
166 | } |
||
167 | |||
168 | public void close() |
||
169 | {} |
||
170 | |||
171 | public void connect() throws IOException, DriverException { |
||
172 | //wms.getCapabilities();
|
||
173 | //wms = new WMSClient(getHost()); //
|
||
174 | try {
|
||
175 | wms.getCapabilities(); |
||
176 | setConnected(true);
|
||
177 | } catch (Exception e) { |
||
178 | throw new DriverException(e); |
||
179 | } |
||
180 | } |
||
181 | } |