root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / wfs / FMapWFSDriver.java @ 4886
History | View | Annotate | Download (5.07 KB)
1 |
package com.iver.cit.gvsig.fmap.drivers.wfs; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.net.ConnectException; |
5 |
import java.net.URL; |
6 |
import java.util.Hashtable; |
7 |
import java.util.Iterator; |
8 |
import java.util.Vector; |
9 |
|
10 |
import org.gvsig.remoteClient.wfs.WFSClient; |
11 |
import org.gvsig.remoteClient.wfs.WFSProtocolHandler.ServiceInformation; |
12 |
|
13 |
import com.iver.cit.gvsig.fmap.DriverException; |
14 |
import com.iver.cit.gvsig.fmap.drivers.UnsupportedVersionException; |
15 |
import com.iver.cit.gvsig.fmap.drivers.WFSDriver; |
16 |
import com.iver.cit.gvsig.fmap.drivers.WFSException; |
17 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
18 |
|
19 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
20 |
*
|
21 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
22 |
*
|
23 |
* This program is free software; you can redistribute it and/or
|
24 |
* modify it under the terms of the GNU General Public License
|
25 |
* as published by the Free Software Foundation; either version 2
|
26 |
* of the License, or (at your option) any later version.
|
27 |
*
|
28 |
* This program is distributed in the hope that it will be useful,
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
31 |
* GNU General Public License for more details.
|
32 |
*
|
33 |
* You should have received a copy of the GNU General Public License
|
34 |
* along with this program; if not, write to the Free Software
|
35 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
36 |
*
|
37 |
* For more information, contact:
|
38 |
*
|
39 |
* Generalitat Valenciana
|
40 |
* Conselleria d'Infraestructures i Transport
|
41 |
* Av. Blasco Ib??ez, 50
|
42 |
* 46010 VALENCIA
|
43 |
* SPAIN
|
44 |
*
|
45 |
* +34 963862235
|
46 |
* gvsig@gva.es
|
47 |
* www.gvsig.gva.es
|
48 |
*
|
49 |
* or
|
50 |
*
|
51 |
* IVER T.I. S.A
|
52 |
* Salamanca 50
|
53 |
* 46005 Valencia
|
54 |
* Spain
|
55 |
*
|
56 |
* +34 963163400
|
57 |
* dac@iver.es
|
58 |
*/
|
59 |
/* CVS MESSAGES:
|
60 |
*
|
61 |
* $Id: FMapWFSDriver.java 4886 2006-04-19 12:50:16Z jorpiell $
|
62 |
* $Log$
|
63 |
* Revision 1.1 2006-04-19 12:50:16 jorpiell
|
64 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
|
65 |
*
|
66 |
*
|
67 |
*/
|
68 |
/**
|
69 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
70 |
*/
|
71 |
public class FMapWFSDriver implements WFSDriver{ |
72 |
private WFSClient client;
|
73 |
private WFSLayerNode fmapRootLayer;
|
74 |
|
75 |
/*
|
76 |
* (non-Javadoc)
|
77 |
* @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#getCapabilities(java.net.URL)
|
78 |
*/
|
79 |
public void getCapabilities(URL server) |
80 |
throws WFSException {
|
81 |
try {
|
82 |
getClient(server).connect(); |
83 |
} catch (Exception e) { |
84 |
throw new WFSException(e); |
85 |
} |
86 |
|
87 |
} |
88 |
|
89 |
|
90 |
/**
|
91 |
* Devuelve WFSClient a partir de su URL.
|
92 |
*
|
93 |
* @param url URL.
|
94 |
*
|
95 |
* @return WMSClient.
|
96 |
* @throws IOException
|
97 |
* @throws ConnectException
|
98 |
*
|
99 |
* @throws UnsupportedVersionException
|
100 |
* @throws IOException
|
101 |
*/
|
102 |
public WFSClient getClient(URL url) throws ConnectException, IOException { |
103 |
if (client == null) { |
104 |
client = new WFSClient(url.toString());
|
105 |
} |
106 |
|
107 |
return client;
|
108 |
} |
109 |
|
110 |
/**
|
111 |
* Creates a new instance of a WFSClient.
|
112 |
* @param
|
113 |
* host
|
114 |
* @throws IOException
|
115 |
* @throws ConnectException
|
116 |
*/
|
117 |
public void createClient(URL host) throws ConnectException, IOException { |
118 |
client = new WFSClient(host.toString());
|
119 |
} |
120 |
|
121 |
/**
|
122 |
* Establishes the connection to the WfS server. Connecting to a WFS is
|
123 |
* an abstraction.<br>
|
124 |
* <p>
|
125 |
* Actually, it sends a GetCapabilities request to read the necessary
|
126 |
* data for building further DescribeFeatureType requests.
|
127 |
* </p>
|
128 |
* @throws IOException, DriverException.
|
129 |
*/
|
130 |
public boolean connect() throws IOException, DriverException { |
131 |
return client.connect();
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* @return The title of the service offered by the WMS server.
|
136 |
*/
|
137 |
public String getServiceTitle() { |
138 |
return client.getServiceInformation().title;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* @return The abstract of the service offered by the WMS server.
|
143 |
*/
|
144 |
public String getServiceAbstract() { |
145 |
return client.getServiceInformation().abstr;
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* Returns a Hash table containing the values for each online resource.
|
150 |
* Using as key a String with name of the WMS request and the value returned
|
151 |
* by the hash is another string containing the corresponding Url
|
152 |
* @return HashTable
|
153 |
*/
|
154 |
public Hashtable getOnlineResources() { |
155 |
Hashtable onlineResources = new Hashtable(); |
156 |
ServiceInformation si = client.getServiceInformation(); |
157 |
Iterator it = si.operations.keySet().iterator();
|
158 |
while (it.hasNext()) {
|
159 |
String key = (String) it.next(); |
160 |
String val = (String) si.operations.get(key); |
161 |
if (val==null && (si.online_resource!=null || si.online_resource!= "")) |
162 |
val = si.online_resource; |
163 |
if (val!=null) { |
164 |
onlineResources.put(key, val); |
165 |
} |
166 |
} |
167 |
return onlineResources;
|
168 |
} |
169 |
|
170 |
/**
|
171 |
* Returns the feature list
|
172 |
* @return Features vector
|
173 |
*/
|
174 |
public Vector getFeatures(){ |
175 |
return client.getFeatures();
|
176 |
} |
177 |
|
178 |
/**
|
179 |
*
|
180 |
* @return the host
|
181 |
*/
|
182 |
public String getHost(){ |
183 |
return client.getHost();
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* @return the version of this client.
|
188 |
*/
|
189 |
public String getVersion() { |
190 |
return client.getVersion();
|
191 |
} |
192 |
|
193 |
|
194 |
} |