Statistics
| Revision:

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

History | View | Annotate | Download (5.55 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.hardcode.gdbms.driver.exceptions.ReadDriverException;
52
import com.iver.andami.PluginServices;
53
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
54
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriverFactory;
55
import com.iver.cit.gvsig.fmap.layers.WCSLayer;
56
import com.iver.cit.gvsig.gui.wizards.WizardData;
57

    
58

    
59

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

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

    
75

    
76
    public void setHost(URL host, boolean override) throws ReadDriverException{
77
        try {
78
                wcs = FMapWCSDriverFactory.getFMapDriverForURL(host);
79

    
80
                        //wcs.createClient(host);
81

    
82
        // Send getCapabilities and describe coverage request;
83
                if (!wcs.connect(override, null))
84
            throw new ReadDriverException(host.getPath(),null);
85
        } catch (ConnectException e) {
86
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this,"wcs_server_timeout"));
87
                        return;
88
                } catch (IOException e) {
89
                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "wcs_cant_connect"));
90
                        return;
91
                }
92

    
93
                if (wcs.getLabel()!=null)
94
                        title = wcs.getLabel();
95

    
96
        if (wcs.getDescription()  != null)
97
            theAbstract = wcs.getDescription();
98

    
99
        coverageList = wcs.getLayerList();
100
    }
101

    
102
    /**
103
     * The server description.
104
     *
105
     * La descripci?n del servidor
106
     * @return String
107
     */
108
    public String getAbstract() {
109
            if (theAbstract == null) return "None";
110
        return theAbstract;
111
    }
112

    
113
    /**
114
     * An ArrayList with the coverage formats.
115
     *
116
     * Los formatos de la cobertura
117
     *
118
     * @return
119
     */
120
    public ArrayList getCoverageFormatos(String nomCobertura) {
121
        return getLayer(nomCobertura).getFormats();
122
    }
123

    
124
    /**
125
     * Finds the coverage within the coverage list
126
     *
127
     * Busca la cobertura en la lista de coberturas
128
     *
129
     * @return CoverageInfo
130
     */
131
    public WCSLayer getLayer(String name) {
132
            for (int i = 0; i < coverageList.length; i++) {
133
                        if (coverageList[i].getName().equals(name))
134
                                return coverageList[i];
135
                }
136
            return null;
137
    }
138

    
139
    /**
140
     * Returns an ArrayList containing the supported SRS of the coverage specified
141
     * by name.
142
     *
143
     * Devuelve una lista de SRSs soportados por la cobertura "name".
144
     *
145
     * @param name
146
     * @return ArrayList
147
     */
148
    public ArrayList getCoverageSRSs(String name){
149
            return getLayer(name).getSRSs();
150
    }
151
    /**
152
     * Server's title (not used in gvSIG)
153
     *
154
     * T?tulo del servidor (no se usa en gvSIG)
155
     *
156
     * @return
157
     */
158
    public String getTitle() {
159
            if (title == null) return "None";
160
        return title;
161
    }
162

    
163
    /**
164
     * Equivalent to the setDescription method
165
     *
166
     * Equivalente a setDescription
167
     *
168
     * @param string
169
     */
170
    public void setAbstract(String string) {
171
        theAbstract = string;
172
    }
173

    
174
    /**
175
     * Sets the server's title (not used in gvSIG)
176
     *
177
     * Establece el t?tulo del servidor (no se usa en gvSIG)
178
     *
179
     * @param string
180
     */
181
    public void setTitle(String string) {
182
        title = string;
183
    }
184

    
185
    /**
186
     * Sets the server's description.
187
     *
188
     * Establece la descripci?n del servidor.
189
     * @param String
190
     */
191
    public void setDescription(String s) {
192
            setAbstract(s);
193
    }
194

    
195
    /**
196
     * Returns the server's descrition
197
     *
198
     * Recupera la descripci?n del servidor
199
     * @return "None" if the server doesn't specify any description
200
     */
201
    public String getDescription(){
202
            if (getAbstract() == null) return "None";
203
            return getAbstract();
204
    }
205

    
206
        public WCSLayer[] getCoverageList() {
207
                if (coverageList == null)
208
                        coverageList = new WCSLayer[0];
209
                return coverageList;
210
        }
211

    
212
        public FMapWCSDriver getDriver() {
213
                return wcs;
214
        }
215

    
216
        public String getHost() {
217
                return wcs.getHost();
218
        }
219

    
220
        public String getServerType() {
221
                if (wcs.getVersion()==null) return "WCS";
222
                return "WCS "+wcs.getVersion();
223
        }
224

    
225

    
226
}