Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / wcs / WCSWizardData.java @ 4505

History | View | Annotate | Download (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.gui.wcs;
42

    
43
import java.awt.Component;
44
import java.io.IOException;
45
import java.net.ConnectException;
46
import java.net.URL;
47
import java.util.ArrayList;
48

    
49
import javax.swing.JOptionPane;
50

    
51
import com.iver.andami.PluginServices;
52
import com.iver.cit.gvsig.fmap.DriverException;
53
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
54
import com.iver.cit.gvsig.fmap.layers.WCSLayer;
55
import com.iver.cit.gvsig.gui.wizards.WizardData;
56

    
57

    
58

    
59
/**
60
 * This class holds the WCSWizard's info
61
 * 
62
 * Contiene la informaci?n del asistente WCS
63
 * 
64
 * @author jaume - jaume.dominguez@iver.es
65
 *
66
 */
67

    
68
public class WCSWizardData extends WizardData{
69
    private String title;
70
    private String Abstract;
71
    private FMapWCSDriver wcs;
72
        private String theAbstract;
73
        private WCSLayer[] coverageList;
74

    
75
    
76
    public void setHost(URL host) throws DriverException{
77
        wcs = new FMapWCSDriver();
78
              try {
79
                        wcs.createClient(host);
80
                
81
        // Send getCapabilities and describe coverage request;
82
                if (!wcs.connect())
83
            throw new DriverException(PluginServices.getText(this, "cant_connect") + host.toString());
84
        } catch (ConnectException e) {
85
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this,"server_timeout"));
86
                        e.printStackTrace();
87
                        return;
88
                } catch (IOException e) {
89
                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "cant_connect"));
90
                        e.printStackTrace();
91
                        return;
92
                }
93
        if (wcs.getDescription()  != null)
94
            theAbstract = wcs.getDescription();
95
        
96
        coverageList = wcs.getLayerList();
97
    }
98
    
99
    /**
100
     * The server description.
101
     * 
102
     * La descripci?n del servidor
103
     * @return String
104
     */
105
    public String getAbstract() {
106
            if (Abstract == null) return "None";
107
        return Abstract;
108
    }
109
    
110
    /**
111
     * An ArrayList with the coverage formats.
112
     * 
113
     * Los formatos de la cobertura
114
     *
115
     * @return
116
     */ 
117
    public ArrayList getCoverageFormatos(String nomCobertura) {
118
        return getLayer(nomCobertura).getFormats();
119
    }
120

    
121
    /**
122
     * Finds the coverage within the coverage list
123
     * 
124
     * Busca la cobertura en la lista de coberturas
125
     *
126
     * @return CoverageInfo
127
     */
128
    public WCSLayer getLayer(String name) {
129
            for (int i = 0; i < coverageList.length; i++) {
130
                        if (coverageList[i].getName().equals(name))
131
                                return coverageList[i];
132
                }
133
            return null;
134
    }
135
    
136
    /**
137
     * Returns an ArrayList containing the supported SRS of the coverage specified 
138
     * by name.
139
     * 
140
     * Devuelve una lista de SRSs soportados por la cobertura "name".
141
     * 
142
     * @param name
143
     * @return ArrayList
144
     */
145
    public ArrayList getCoverageSRSs(String name){
146
            return getLayer(name).getSRSs();
147
    }
148
    /**
149
     * Server's title (not used in gvSIG)
150
     * 
151
     * T?tulo del servidor (no se usa en gvSIG)
152
     *
153
     * @return
154
     */
155
    public String getTitle() {
156
            if (title == null) return "None";
157
        return title;
158
    }
159

    
160
    /**
161
     * Equivalent to the setDescription method
162
     * 
163
     * Equivalente a setDescription
164
     *
165
     * @param string
166
     */
167
    public void setAbstract(String string) {
168
        Abstract = string;
169
    }
170

    
171

    
172
//    /**
173
//     * Adds a coverage to the coverages list
174
//     * 
175
//     * A?ande una cobertura a la lista de coberturas
176
//     *
177
//     * @param CoverageInfo
178
//     */
179
//    public void setCoverage(CoverageInfo info) {
180
//        coverages.add(info);
181
//    }
182

    
183
    /**
184
     * Sets the server's title (not used in gvSIG)
185
     * 
186
     * Establece el t?tulo del servidor (no se usa en gvSIG)
187
     *
188
     * @param string
189
     */
190
    public void setTitle(String string) {
191
        title = string;
192
    }
193
    
194
    /**
195
     * Sets the server's description.
196
     * 
197
     * Establece la descripci?n del servidor.
198
     * @param String
199
     */
200
    public void setDescription(String s) {
201
            setAbstract(s);
202
    }
203
    
204
    /**
205
     * Returns the server's descrition
206
     * 
207
     * Recupera la descripci?n del servidor
208
     * @return "None" if the server doesn't specify any description
209
     */
210
    public String getDescription(){
211
            if (getAbstract() == null) return "None";
212
            return getAbstract();
213
    }
214

    
215
        public WCSLayer[] getCoverageList() {
216
                return coverageList;
217
        }
218
        
219
        public FMapWCSDriver getDriver() {
220
                return wcs;
221
        }
222

    
223
        public String getHost() {
224
                return wcs.getHost();
225
        }
226

    
227
        public String getServerType() {
228
                return null;
229
        }
230
        
231
//        /**
232
//         * Sets the coverage names
233
//         * 
234
//         * @param String[] coverageNames
235
//         */
236
//        public void setCoverageNames(String[] coverageNames) {
237
//                this.coverageNames = coverageNames;
238
//        }
239
//        
240
//        /** 
241
//         * Sets the coverages list from an ArrayList
242
//         * 
243
//         * @param coverages
244
//         */
245
//        public void setCoveragesList(ArrayList coverages){
246
//                this.coverages = coverages;
247
//        }
248
//
249
//        /**
250
//         * Returns an ArrayList containing the positions for the TIME
251
//         * 
252
//         * Devuelve las posiciones del tiempo
253
//         * @param string
254
//         * @return
255
//         */
256
//        public ArrayList getCoverageTimes(String name) {
257
//                   CoverageInfo ci = getCoverageInfo(name);
258
//                   if (ci.getTimes()== null) return new ArrayList();
259
//            return ci.getTimes();
260
//         }
261
//        
262
//        /**
263
//         * Returns an ArrayList containing a list of Parametro with the parameters list
264
//         * and its possible values of a coverage specified by its name.
265
//         * 
266
//         * Devuelve la lista de par?metros (y sus posibles valores) de la cobertura y sus
267
//         * posibles valores de una cobertura especificada por su nombre
268
//         * 
269
//         * @return ArrayList
270
//         */
271
//                
272
//        public ArrayList getCoverageParameters(String name){
273
//                CoverageInfo ci = getCoverageInfo(name);
274
//                return ci.getParametros();
275
//        }
276
//
277
//        /**
278
//         * Gets the coverage label.
279
//         */
280
//        public String getCoverageLabel(String name) {
281
//                CoverageInfo ci = getCoverageInfo(name);
282
//                return ci.getLabel();
283
//        }
284

    
285

    
286
}