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 | 4887 | jorpiell | package org.gvsig.remoteClient.wfs; |
---|---|---|---|
2 | |||
3 | 5368 | jorpiell | import java.io.File; |
4 | 4887 | jorpiell | import java.io.IOException; |
5 | import java.net.ConnectException; |
||
6 | import java.util.Hashtable; |
||
7 | 5368 | jorpiell | import java.util.Vector; |
8 | 4887 | jorpiell | |
9 | import org.gvsig.remoteClient.RemoteClient; |
||
10 | 5431 | jorpiell | import org.gvsig.remoteClient.wms.ICancellable; |
11 | 5368 | jorpiell | import org.gvsig.remoteClient.wms.WMSProtocolHandler; |
12 | 4887 | jorpiell | |
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$
|
||
56 | * $Log$
|
||
57 | 5830 | jorpiell | * 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 | 5431 | jorpiell | * Se ha a?adido un atributo al m?todo connect
|
62 | *
|
||
63 | * Revision 1.6 2006/05/23 13:23:22 jorpiell
|
||
64 | 5368 | jorpiell | * Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
|
65 | 5132 | jaume | *
|
66 | * Revision 1.4 2006/04/20 16:39:16 jorpiell
|
||
67 | 4912 | jorpiell | * A?adida la operacion de describeFeatureType y el parser correspondiente.
|
68 | *
|
||
69 | * Revision 1.3 2006/04/19 12:51:35 jorpiell
|
||
70 | 4887 | jorpiell | * 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 | 5368 | jorpiell | |
82 | 4887 | jorpiell | /**
|
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 | 5368 | jorpiell | * 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 | 5830 | jorpiell | public void getCapabilities(WFSStatus status, boolean override, ICancellable cancel) { |
114 | handler.getCapabilities(status,override,cancel); |
||
115 | 5368 | jorpiell | } |
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 | 4887 | jorpiell | * <p>Checks the connection to de remote WFS and requests its
|
151 | * capabilities.</p>
|
||
152 | *
|
||
153 | */
|
||
154 | 5830 | jorpiell | public boolean connect(boolean override,ICancellable cancel) |
155 | 4887 | jorpiell | { |
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 | 5830 | jorpiell | getCapabilities(null,override,cancel);
|
167 | 4887 | jorpiell | |
168 | return true; |
||
169 | |||
170 | } catch (Exception e) { |
||
171 | e.printStackTrace(); |
||
172 | return false; |
||
173 | } |
||
174 | } |
||
175 | |||
176 | /*
|
||
177 | * (non-Javadoc)
|
||
178 | 5830 | jorpiell | * @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 | 4887 | jorpiell | * @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 | 5368 | jorpiell | } |
197 | |||
198 | 4887 | jorpiell | /**
|
199 | * Gets the Service information included in the Capabilities
|
||
200 | */
|
||
201 | |||
202 | public WFSProtocolHandler.ServiceInformation getServiceInformation()
|
||
203 | { |
||
204 | return handler.getServiceInformation();
|
||
205 | } |
||
206 | |||
207 | 4912 | jorpiell | /**
|
208 | * Returns the features list
|
||
209 | * @return
|
||
210 | */
|
||
211 | public Hashtable getFeatures() |
||
212 | 4887 | jorpiell | { |
213 | return handler.getFeatures();
|
||
214 | 5431 | jorpiell | } |
215 | 4887 | jorpiell | |
216 | } |