svn-gvsig-desktop / tags / v1_0_RELEASE / libraries / libRemoteServices / src / org / gvsig / remoteClient / wfs / WFSClient.java @ 9167
History | View | Annotate | Download (5.79 KB)
1 |
package org.gvsig.remoteClient.wfs; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.IOException; |
5 |
import java.net.ConnectException; |
6 |
import java.util.Hashtable; |
7 |
import java.util.Vector; |
8 |
|
9 |
import org.gvsig.remoteClient.RemoteClient; |
10 |
import org.gvsig.remoteClient.wms.ICancellable; |
11 |
import org.gvsig.remoteClient.wms.WMSProtocolHandler; |
12 |
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
14 |
*
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
16 |
*
|
17 |
* This program is free software; you can redistribute it and/or
|
18 |
* modify it under the terms of the GNU General Public License
|
19 |
* as published by the Free Software Foundation; either version 2
|
20 |
* of the License, or (at your option) any later version.
|
21 |
*
|
22 |
* This program is distributed in the hope that it will be useful,
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
* GNU General Public License for more details.
|
26 |
*
|
27 |
* You should have received a copy of the GNU General Public License
|
28 |
* along with this program; if not, write to the Free Software
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
30 |
*
|
31 |
* For more information, contact:
|
32 |
*
|
33 |
* Generalitat Valenciana
|
34 |
* Conselleria d'Infraestructures i Transport
|
35 |
* Av. Blasco Ib??ez, 50
|
36 |
* 46010 VALENCIA
|
37 |
* SPAIN
|
38 |
*
|
39 |
* +34 963862235
|
40 |
* gvsig@gva.es
|
41 |
* www.gvsig.gva.es
|
42 |
*
|
43 |
* or
|
44 |
*
|
45 |
* IVER T.I. S.A
|
46 |
* Salamanca 50
|
47 |
* 46005 Valencia
|
48 |
* Spain
|
49 |
*
|
50 |
* +34 963163400
|
51 |
* dac@iver.es
|
52 |
*/
|
53 |
/* CVS MESSAGES:
|
54 |
*
|
55 |
* $Id: WFSClient.java 9167 2006-12-04 16:01:24Z $
|
56 |
* $Log$
|
57 |
* Revision 1.8 2006-06-14 08:46:07 jorpiell
|
58 |
* Se tiene en cuanta la opcion para refrescar las capabilities
|
59 |
*
|
60 |
* Revision 1.7 2006/05/25 10:28:25 jorpiell
|
61 |
* Se ha a?adido un atributo al m?todo connect
|
62 |
*
|
63 |
* Revision 1.6 2006/05/23 13:23:22 jorpiell
|
64 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
|
65 |
*
|
66 |
* Revision 1.4 2006/04/20 16:39:16 jorpiell
|
67 |
* A?adida la operacion de describeFeatureType y el parser correspondiente.
|
68 |
*
|
69 |
* Revision 1.3 2006/04/19 12:51:35 jorpiell
|
70 |
* A?adidas algunas de las clases del servicio WFS
|
71 |
*
|
72 |
*
|
73 |
*/
|
74 |
/**
|
75 |
* Represents the class the with the necessary logic to connect to a
|
76 |
* OGCWFS and interpretate the data
|
77 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
78 |
*/
|
79 |
public class WFSClient extends RemoteClient{ |
80 |
private WFSProtocolHandler handler;
|
81 |
|
82 |
/**
|
83 |
* Constructor.
|
84 |
* the parameter host, indicates the WFS host to connect.
|
85 |
* @throws ConnectException,IOException
|
86 |
*
|
87 |
*/
|
88 |
public WFSClient(String host) throws ConnectException,IOException { |
89 |
setHost(host); |
90 |
|
91 |
try {
|
92 |
handler = WFSProtocolHandlerFactory.negotiate(host); |
93 |
handler.setHost(host); |
94 |
} catch(ConnectException conE) { |
95 |
conE.printStackTrace(); |
96 |
throw conE;
|
97 |
} catch(IOException ioE) { |
98 |
ioE.printStackTrace(); |
99 |
throw ioE;
|
100 |
} catch(Exception e) { |
101 |
e.printStackTrace(); |
102 |
} |
103 |
} |
104 |
|
105 |
/**
|
106 |
* Every OGC Web Service (OWS), including a Web Feature Service,
|
107 |
* must have the ability to describe its capabilities by returning
|
108 |
* service metadata in response to a GetCapabilities request.
|
109 |
* @param status
|
110 |
* WFS client status. Contains all the information to create
|
111 |
* the query
|
112 |
*/
|
113 |
public void getCapabilities(WFSStatus status, boolean override, ICancellable cancel) { |
114 |
handler.getCapabilities(status,override,cancel); |
115 |
} |
116 |
|
117 |
/**
|
118 |
* The function of the DescribeFeatureType operation is to
|
119 |
* generate a schema description of feature types serviced
|
120 |
* by a WFS implementation. The schema descriptions define
|
121 |
* how a WFS implementation expects feature instances to
|
122 |
* be encoded on input (via Insert and Update requests)
|
123 |
* and how feature instances will be generated on output
|
124 |
* (in response to GetFeature and GetGmlObject requests).
|
125 |
* @param status
|
126 |
* WFS client status. Contains all the information to create
|
127 |
* the query
|
128 |
*/
|
129 |
public void describeFeatureType(WFSStatus status) { |
130 |
handler.describeFeatureType(status); |
131 |
} |
132 |
|
133 |
/**
|
134 |
* The GetFeature operation allows retrieval of features from a
|
135 |
* web feature service. A GetFeature request is processed by
|
136 |
* a WFS and when the value of the outputFormat attribute is
|
137 |
* set to text/gml a GML instance document, containing the
|
138 |
* result set, is returned to the client.
|
139 |
* @param status
|
140 |
* WFS client status. Contains all the information to create
|
141 |
* the query
|
142 |
* @return File
|
143 |
* GML File
|
144 |
*/
|
145 |
public File getFeature(WFSStatus status){ |
146 |
return handler.getFeature(status);
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* <p>Checks the connection to de remote WFS and requests its
|
151 |
* capabilities.</p>
|
152 |
*
|
153 |
*/
|
154 |
public boolean connect(boolean override,ICancellable cancel) |
155 |
{ |
156 |
try {
|
157 |
if (handler == null) { |
158 |
if (getHost().trim().length() > 0) { |
159 |
handler = WFSProtocolHandlerFactory.negotiate(getHost()); |
160 |
handler.setHost(getHost()); |
161 |
} else {
|
162 |
// must to specify host first!!!!
|
163 |
return false; |
164 |
} |
165 |
} |
166 |
getCapabilities(null,override,cancel);
|
167 |
|
168 |
return true; |
169 |
|
170 |
} catch (Exception e) { |
171 |
e.printStackTrace(); |
172 |
return false; |
173 |
} |
174 |
} |
175 |
|
176 |
/*
|
177 |
* (non-Javadoc)
|
178 |
* @see org.gvsig.remoteClient.RemoteClient#connect(org.gvsig.remoteClient.wms.ICancellable)
|
179 |
*/
|
180 |
public boolean connect(ICancellable cancel) { |
181 |
return connect(false, cancel); |
182 |
} |
183 |
|
184 |
/*
|
185 |
* (non-Javadoc)
|
186 |
* @see org.gvsig.remoteClient.RemoteClient#close()
|
187 |
*/
|
188 |
public void close() { |
189 |
// TODO Auto-generated method stub
|
190 |
|
191 |
} |
192 |
|
193 |
public String getVersion() |
194 |
{ |
195 |
return handler.getVersion();
|
196 |
} |
197 |
|
198 |
/**
|
199 |
* Gets the Service information included in the Capabilities
|
200 |
*/
|
201 |
|
202 |
public WFSProtocolHandler.ServiceInformation getServiceInformation()
|
203 |
{ |
204 |
return handler.getServiceInformation();
|
205 |
} |
206 |
|
207 |
/**
|
208 |
* Returns the features list
|
209 |
* @return
|
210 |
*/
|
211 |
public Hashtable getFeatures() |
212 |
{ |
213 |
return handler.getFeatures();
|
214 |
} |
215 |
|
216 |
} |