Statistics
| Revision:

root / trunk / extensions / extWMS / src / com / iver / cit / gvsig / gui / wizards / WMSWizardData.java @ 5831

History | View | Annotate | Download (4.36 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.Component;
44
import java.awt.geom.Rectangle2D;
45
import java.io.IOException;
46
import java.net.ConnectException;
47
import java.net.URL;
48
import java.util.ArrayList;
49
import java.util.Hashtable;
50
import java.util.Vector;
51

    
52
import javax.swing.JOptionPane;
53

    
54
import com.iver.andami.PluginServices;
55
import com.iver.cit.gvsig.fmap.DriverException;
56
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver;
57
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory;
58
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode;
59

    
60

    
61
/**
62
 * Class holding the data shown at the wms wizards
63
 *
64
 * @author Jaume Dominguez Faus
65
 */
66
public class WMSWizardData { // should implemement any kind of wizard data interface?
67
    private String title;
68
    private String theAbstract;
69
    private WMSLayerNode layer;
70
    private String[] formats;
71
    private String serverVersion;
72
    private FMapWMSDriver wms = null;
73
    private Hashtable onlineResources = null;
74
    
75
    /**
76
     * @return Returns the serverVersion.
77
     */
78
    public String getServerVersion() {
79
        return serverVersion;
80
    }
81
    public String getHost(){
82
        return wms.getHost();
83
    }
84
    
85
    public void setHost(URL host, boolean override) throws DriverException{        
86
        try {
87
                wms = FMapWMSDriverFactory.getFMapDriverForURL(host);
88
                
89
                // Send a getCapabilities request;
90
                if (!wms.connect(override, null))
91
                        throw new DriverException(PluginServices.getText(this, "cant_connect") + host.toString());
92
        } catch (ConnectException e) {
93
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this,"server_timeout"));
94
                        e.printStackTrace();
95
                        return;
96
                } catch (IOException e) {
97
                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "cant_connect"));
98
                        e.printStackTrace();
99
                        return;
100
                }
101
        if (wms.getAbstract()  != null)
102
            theAbstract = wms.getAbstract();
103
        
104
        Vector f = wms.getFormats(); 
105
        ArrayList formatos = new ArrayList();
106
        for (int i = 0; i < f.size(); i++) {
107
                formatos.add(f.elementAt(i));
108
        }
109
        formats = (String[]) formatos.toArray(new String[0]);
110
        serverVersion = (wms.getVersion() == null) ? "" : wms.getVersion();
111
        onlineResources = wms.getOnlineResources();
112
        layer = wms.getLayersTree(); // LayersTree as they are defined in the Capabilities document
113
    }
114
    
115
    public String getAbstract() {
116
        return theAbstract;
117
    }
118

    
119
    public String[] getFormats() {
120
        return formats;
121
    }
122

    
123
    public WMSLayerNode getLayer() {
124
        return layer;
125
    }
126

    
127
    public String getTitle() {
128
        return title;
129
    }
130

    
131
    public String getServerType() {
132
            if (serverVersion==null) return "WMS";
133
        return "WMS "+serverVersion;
134
    }
135

    
136
    public Hashtable getOnlineResources() {
137
                return onlineResources;
138
        }
139

    
140
    public Rectangle2D getBoundingBox(String[] layerNames, String srs) {
141
        return wms.getLayersExtent(layerNames, srs);
142
    }
143
    
144
        public FMapWMSDriver getDriver() {
145
                return wms;
146
        }
147
        
148
    public boolean isQueryable() {
149
            return wms.isQueryable();
150
    }
151
 
152
}