Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / fmap / drivers / wcs / FMapWCSDriver.java @ 4414

History | View | Annotate | Download (8.7 KB)

1
/* 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 com.iver.cit.gvsig.fmap.drivers.wcs;
42

    
43
import java.awt.geom.Point2D;
44
import java.awt.geom.Rectangle2D;
45
import java.io.File;
46
import java.io.IOException;
47
import java.net.ConnectException;
48
import java.net.URL;
49
import java.util.ArrayList;
50
import java.util.Hashtable;
51
import java.util.Iterator;
52

    
53
import org.gvsig.remoteClient.wcs.WCSClient;
54
import org.gvsig.remoteClient.wcs.WCSCoverage;
55
import org.gvsig.remoteClient.wcs.WCSStatus;
56

    
57
import com.iver.cit.gvsig.fmap.DriverException;
58
import com.iver.cit.gvsig.fmap.drivers.RemoteServiceDriver;
59
import com.iver.cit.gvsig.fmap.drivers.WCSException;
60
import com.iver.cit.gvsig.fmap.layers.WCSLayer;
61

    
62

    
63

    
64
/**
65
 * Driver between the FMap and WCSClient
66
 * 
67
 * Controlador entre FMap y WCSClient
68
 * 
69
 * @author jaume
70
 *
71
 */
72
public class FMapWCSDriver extends RemoteServiceDriver {
73
        private WCSClient client = null;
74
        private WCSCoverage[] layers;
75
        private Hashtable coverages;
76
        private WCSLayer[] layerList;
77
        
78
        /**
79
         * Returns the string "WCSDriver", which is the driver's name.
80
         * 
81
         * Devuelve "WCSDriver", el nombre del driver.
82
         * @return String 
83
         */
84
        public String getName() { return "WCSDriver"; } 
85
        
86
        /**
87
         * Sets the server that we want to connect to.
88
         * 
89
         * Establece el servidor al que se quiere conectar.
90
         * 
91
         * @param host
92
         * @throws IOException 
93
         */
94
        public void setHost(String host) throws IOException{
95
                super.setHost(host);
96
                setServiceName("WCS"); 
97
                client = new WCSClient(host);
98
        }
99
        
100
        
101
        /**
102
         * Returns a human-readable string containing the server's name.
103
         * 
104
         * Devuelve el nombre legible del servidor devuelto por ?ste.
105
         * 
106
         * @return String
107
         */ 
108
        public String getLabel() {
109
                return client.getServiceTitle();
110
        }
111
        
112
        /**
113
         * Returns a string containing the server's WCS version number.
114
         * 
115
         * Devuelve el n?mero de versi?n WCS del servidor
116
         * 
117
         * @return String
118
         */
119
        public String getVersion(){
120
                return client.getVersion();
121
        }
122
        
123
        /**
124
         * <p>
125
         * Returns name and description of the server. It is supposed to be used
126
         * as the source of the abstract field in your application's interface.
127
         * </p>
128
         * <p>
129
         * Devuelve nombre y descripci?n (abstract) del servidor.
130
         * </p>
131
         * @return String
132
         */
133
        public String getDescription(){
134
                return client.getDescription();
135
        }
136
        
137
        
138
        /**
139
         * Returns a list containing the formats supported by the coverage
140
         * 
141
         * Devuelve una lista de formatos soportados por la cobertura.
142
         * 
143
         * @param coverage
144
         * @return ArrayList
145
         */
146
        public ArrayList getFormats(String coverage){
147
                return client.getFormats();
148
        }
149
        
150
        
151
        public WCSLayer[] getLayerList(){
152
                if (coverages == null) {
153
                        // the WCSLayer collection will be built
154
                        coverages = new Hashtable();
155
                        Hashtable wcsCoverages  = client.getCoverageList();
156
                        int sz = wcsCoverages.size();
157
                        
158
                        // Create an array with the WCSCoverages
159
                        WCSCoverage[] coverageList = new WCSCoverage[sz];
160
                        Iterator it = wcsCoverages.keySet().iterator();
161
                        int i = 0;
162
                        while (it.hasNext()) {
163
                                coverageList[i] = (WCSCoverage) wcsCoverages.get(it.next());
164
                                i++;
165
                        }
166
                        
167
                        // Create a WCSLayer array from the previous WCSCoverage array
168
                        layerList = new WCSLayer[sz];
169
                        for (int j = 0; j < layerList.length; j++) {
170
                                WCSLayer lyr = new WCSLayer();
171
                                WCSCoverage cov = coverageList[j];
172
                                lyr.setName(cov.getName());
173
                                lyr.setTitle(cov.getTitle());
174
                                lyr.setDescription(cov.getAbstract());
175
                                lyr.addAllSrs(cov.getAllSrs());
176
                                lyr.setNativeSRS(cov.getNativeSRS());
177
                                lyr.setFormats(cov.getFormats());
178
                                lyr.setTimePositions(cov.getTimePositions());
179
                                lyr.setMaxRes(new Point2D.Double(cov.getResX(), cov.getResY()));
180
                                // TODO par?metres i time
181
                                layerList[j] = lyr;
182
                                coverages.put(lyr.getName(), lyr);
183
                        }
184
                        
185
                        
186
                }
187
                
188
                return layerList;
189
        }
190
        
191
        /**
192
         * Establishes the connection to the WCS server. Connecting to a WCS is
193
         * an abstraction, it actually sends a GetCapabilities and a general 
194
         * DescribeCoverage request (not a coverage-specific DescribeCoverage request)
195
         * to read the necessary data for building further GetCoverage requests.
196
         * 
197
         * 
198
         * La conexi?n a un servidor WCS es una abstracci?n de dos operaciones:
199
         * GetCapabilities y DescribeCoverage. Con ellas, se obtienen los datos
200
         * necesarios para poder operar con el servidor.
201
         * 
202
         * 
203
         * @throws IOException, DriverException.
204
         */
205
        public boolean connect() throws IOException, DriverException {
206
                return client.connect();
207
        }
208

    
209
        /**
210
         * No close operation is needed since WCS service it is a non-session based
211
         * protocol. So, this does nothing and you can omit it.
212
         * 
213
         * La operaci?n close no es necesaria en un servicio WCS ya que este se implementa
214
         * sobre un protocolo no orientado a sesiones. As? que esto no hace nada y puede
215
         * ser omitido.
216
         * 
217
         */
218
        public void close() {
219
                setConnected(false);
220
        }
221

    
222
        /**
223
         * Returns the label of an specific coverage given by the coverage name
224
         * 
225
         * Obtiene la etiqueta de una cobertura espec?fica
226
         * 
227
         * @param nombre de la cobertura (string)
228
         * @return string
229
         */
230
        public String getLabel(String coverageName) {
231
                return client.getLabel(coverageName);
232
        }
233

    
234
        /**
235
         * Returns the coverage's MAX extent from the server.
236
         * 
237
         * Obtiene la M?XIMA extensi?n de la cobertura de el servidor.
238
         * @return Rectangle2D
239
         * @throws DriverException
240
         * @throws IOException
241
         */
242
        public Rectangle2D getFullExtent(String coverageName, String srs) throws IOException, DriverException {
243
                return client.getExtent(coverageName, srs);
244
        }
245

    
246
        /**
247
         * Returns an Arraylist containing the parameters of the coverage given by
248
         * the coverage name. The list contains a set of Parametro objects.
249
         * 
250
         * Devuelve los par?metros soportados por la cobertura especificada por su nombre.
251
         * La lista contiene un juego de objetos Parametro.
252
         * 
253
         * @return ArrayList de Parametro
254
         */
255
        public ArrayList getParameters(String coverageName) {
256
                // TODO
257
                return null;
258
        }
259
        
260
        /**
261
         * Returns the max resolution of a specific coverage given by the coverage's name.
262
         * 
263
         * Obtiene la resoluci?n m?xima de una cobertura espec?fica
264
         * @param nombre de la cobertura (string)
265
         * @return double
266
         */
267
        public Point2D getMaxResolution(String coverageName) {
268
                // TODO
269
                return null;
270
        }
271

    
272

    
273
        /**
274
         * Returns an ArrayList containing a set of Strings with the coverage's SRSs.
275
         * 
276
         * Obtiene un ArrayList con los SRS de una cobertura espec?fica
277
         * @param Nombre de la cobertura (string)
278
         * @return ArrayList
279
         */
280
        public ArrayList getSRSs(String coverageName) {        
281
                // TODO
282
                return null;
283
        }
284

    
285
        /**
286
         * Returns a String containing a description of an specific coverage.
287
         * 
288
         * Obtiene la descripci?n de una cobertura espec?fica
289
         * @param Nombre de la cobertura (string)
290
         * @return string
291
         */
292
        public String getCoverageDescription(String coverageName) {
293
                // TODO
294
                return null;
295
        }
296

    
297
        /**
298
         * Returns an ArrayList containing strings for the time positions of an
299
         * specific coverage given by the coverage's name.
300
         * 
301
         * Obtiene la lista de tiempos de una cobertura espec?fica
302
         * @param nombre de la cobertura (string)
303
         * @return ArrayList
304
         */
305
        public ArrayList getTimes(String coverageName) {
306
                // TODO
307
                return null;
308

    
309
        }
310

    
311
        public void getCapabilities(WCSStatus status) throws WCSException {
312
                // TODO Auto-generated method stub
313
                
314
        }
315

    
316
        public void describeCoverage(WCSStatus status) throws WCSException {
317
                // TODO Auto-generated method stub
318
                
319
        }
320

    
321
        public File getCoverage(WCSStatus status) throws WCSException {
322
                // TODO Auto-generated method stub
323
                return null;
324
        }
325

    
326
        /**
327
     * Creates a new instance of a WCSClient.
328
     * @param host
329
     * @throws IOException 
330
     * @throws ConnectException 
331
     */
332
        public void createClient(URL host) throws ConnectException, IOException{
333
                client = new WCSClient(host.toString());
334
        } 
335
}