Revision 5294
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/fmap/layers/FLyrWFS.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.layers; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.io.IOException; |
|
5 |
import java.net.URL; |
|
6 |
|
|
7 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
|
8 |
|
|
9 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
|
10 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
11 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
|
12 |
import com.iver.cit.gvsig.fmap.drivers.WFSException; |
|
13 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
|
14 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
|
15 |
import com.iver.cit.gvsig.fmap.operations.strategies.WFSStrategy; |
|
16 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
17 |
|
|
18 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
19 |
* |
|
20 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
21 |
* |
|
22 |
* This program is free software; you can redistribute it and/or |
|
23 |
* modify it under the terms of the GNU General Public License |
|
24 |
* as published by the Free Software Foundation; either version 2 |
|
25 |
* of the License, or (at your option) any later version. |
|
26 |
* |
|
27 |
* This program is distributed in the hope that it will be useful, |
|
28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
30 |
* GNU General Public License for more details. |
|
31 |
* |
|
32 |
* You should have received a copy of the GNU General Public License |
|
33 |
* along with this program; if not, write to the Free Software |
|
34 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
35 |
* |
|
36 |
* For more information, contact: |
|
37 |
* |
|
38 |
* Generalitat Valenciana |
|
39 |
* Conselleria d'Infraestructures i Transport |
|
40 |
* Av. Blasco Ib??ez, 50 |
|
41 |
* 46010 VALENCIA |
|
42 |
* SPAIN |
|
43 |
* |
|
44 |
* +34 963862235 |
|
45 |
* gvsig@gva.es |
|
46 |
* www.gvsig.gva.es |
|
47 |
* |
|
48 |
* or |
|
49 |
* |
|
50 |
* IVER T.I. S.A |
|
51 |
* Salamanca 50 |
|
52 |
* 46005 Valencia |
|
53 |
* Spain |
|
54 |
* |
|
55 |
* +34 963163400 |
|
56 |
* dac@iver.es |
|
57 |
*/ |
|
58 |
/* CVS MESSAGES: |
|
59 |
* |
|
60 |
* $Id$ |
|
61 |
* $Log$ |
|
62 |
* Revision 1.1 2006-05-19 12:54:11 jorpiell |
|
63 |
* Creada la capa WFS |
|
64 |
* |
|
65 |
* |
|
66 |
*/ |
|
67 |
/** |
|
68 |
* FMap's WFS Layer class. |
|
69 |
* |
|
70 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
71 |
*/ |
|
72 |
public class FLyrWFS extends FLyrVect{ |
|
73 |
private URL host = null; |
|
74 |
private String name = null; |
|
75 |
private String layerName = null; |
|
76 |
private String userName = null; |
|
77 |
private String password = null; |
|
78 |
private String[] fields = null; |
|
79 |
private int numfeatures = 100; |
|
80 |
private int timeout = 10000; |
|
81 |
private FMapWFSDriver wfsDriver = null; |
|
82 |
private VectorialAdapter vectorialAdapter = null; |
|
83 |
private WFSStrategy wfsStrategy = null; |
|
84 |
|
|
85 |
|
|
86 |
/** |
|
87 |
* Constructor |
|
88 |
*/ |
|
89 |
public FLyrWFS(){ |
|
90 |
super(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Loads the features from the server |
|
95 |
*/ |
|
96 |
public void load(){ |
|
97 |
WFSAdapter adapter = new WFSAdapter(); |
|
98 |
try { |
|
99 |
wfsDriver.getFeature(getWFSStatus()); |
|
100 |
} catch (WFSException e) { |
|
101 |
// TODO Auto-generated catch block |
|
102 |
e.printStackTrace(); |
|
103 |
} |
|
104 |
|
|
105 |
adapter.setDriver((VectorialDriver) wfsDriver); |
|
106 |
setSource(adapter); |
|
107 |
|
|
108 |
try { |
|
109 |
setLegend(LegendFactory.createSingleSymbolLegend( |
|
110 |
getShapeType())); |
|
111 |
} catch (FieldNotFoundException e) { |
|
112 |
e.printStackTrace(); |
|
113 |
} catch (DriverException e) { |
|
114 |
e.printStackTrace(); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* Gets the WFS Status |
|
120 |
* @return |
|
121 |
*/ |
|
122 |
private WFSStatus getWFSStatus(){ |
|
123 |
WFSStatus status = new WFSStatus(getLayerName()); |
|
124 |
status.setUserName(getUserName()); |
|
125 |
status.setPassword(getPassword()); |
|
126 |
status.setBuffer(getNumfeatures()); |
|
127 |
status.setTimeout(getTimeout()); |
|
128 |
status.setFields(getFields()); |
|
129 |
return status; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* Adds the vectorial adapter to the layer |
|
134 |
* @param vectorialAdapter |
|
135 |
*/ |
|
136 |
public void setSource(VectorialAdapter vectorialAdapter) { |
|
137 |
this.vectorialAdapter = vectorialAdapter; |
|
138 |
super.setSource(vectorialAdapter); |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* @return Returns the layerName. |
|
143 |
*/ |
|
144 |
public String getLayerName() { |
|
145 |
return layerName; |
|
146 |
} |
|
147 |
/** |
|
148 |
* @param layerName The layerName to set. |
|
149 |
*/ |
|
150 |
public void setLayerName(String layerName) { |
|
151 |
this.layerName = layerName; |
|
152 |
} |
|
153 |
/** |
|
154 |
* @return Returns the numfeatures. |
|
155 |
*/ |
|
156 |
public int getNumfeatures() { |
|
157 |
return numfeatures; |
|
158 |
} |
|
159 |
/** |
|
160 |
* @param numfeatures The numfeatures to set. |
|
161 |
*/ |
|
162 |
public void setNumfeatures(int numfeatures) { |
|
163 |
this.numfeatures = numfeatures; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* @return Returns the pwd. |
|
168 |
*/ |
|
169 |
public String getPassword() { |
|
170 |
return password; |
|
171 |
} |
|
172 |
/** |
|
173 |
* @param pwd The pwd to set. |
|
174 |
*/ |
|
175 |
public void setPassword(String password) { |
|
176 |
this.password = password; |
|
177 |
} |
|
178 |
/** |
|
179 |
* @return Returns the timeout. |
|
180 |
*/ |
|
181 |
public int getTimeout() { |
|
182 |
return timeout; |
|
183 |
} |
|
184 |
/** |
|
185 |
* @param timeout The timeout to set. |
|
186 |
*/ |
|
187 |
public void setTimeout(int timeout) { |
|
188 |
this.timeout = timeout; |
|
189 |
} |
|
190 |
/** |
|
191 |
* @return Returns the user. |
|
192 |
*/ |
|
193 |
public String getUserName() { |
|
194 |
return userName; |
|
195 |
} |
|
196 |
/** |
|
197 |
* @param user The user to set. |
|
198 |
*/ |
|
199 |
public void setUserName(String userName) { |
|
200 |
this.userName = userName; |
|
201 |
} |
|
202 |
/** |
|
203 |
* @return Returns the fields. |
|
204 |
*/ |
|
205 |
public String[] getFields() { |
|
206 |
return fields; |
|
207 |
} |
|
208 |
/** |
|
209 |
* @param fields The fields to set. |
|
210 |
*/ |
|
211 |
public void setFields(String[] fields) { |
|
212 |
this.fields = fields; |
|
213 |
} |
|
214 |
/** |
|
215 |
* @return Returns the name. |
|
216 |
*/ |
|
217 |
public String getName() { |
|
218 |
return name; |
|
219 |
} |
|
220 |
/** |
|
221 |
* @param name The name to set. |
|
222 |
*/ |
|
223 |
public void setName(String name) { |
|
224 |
this.name = name; |
|
225 |
} |
|
226 |
/** |
|
227 |
* @return Returns the host. |
|
228 |
*/ |
|
229 |
public URL getHost() { |
|
230 |
return host; |
|
231 |
} |
|
232 |
/** |
|
233 |
* @param host The host to set. |
|
234 |
*/ |
|
235 |
public void setHost(URL host) { |
|
236 |
this.host = host; |
|
237 |
} |
|
238 |
|
|
239 |
/** |
|
240 |
* @return Returns the wfs. |
|
241 |
*/ |
|
242 |
public FMapWFSDriver getWfsDriver() { |
|
243 |
return wfsDriver; |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* @param wfs The wfs to set. |
|
248 |
*/ |
|
249 |
public void setWfsDriver(FMapWFSDriver wfs) { |
|
250 |
this.wfsDriver = wfs; |
|
251 |
} |
|
252 |
|
|
253 |
|
|
254 |
/** |
|
255 |
* @return wfsStrategy |
|
256 |
*/ |
|
257 |
public Strategy getStrategy() { |
|
258 |
if (wfsStrategy == null){ |
|
259 |
wfsStrategy = new WFSStrategy(this); |
|
260 |
} |
|
261 |
return wfsStrategy; |
|
262 |
} |
|
263 |
|
|
264 |
/* |
|
265 |
* (non-Javadoc) |
|
266 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent() |
|
267 |
*/ |
|
268 |
public Rectangle2D getFullExtent() throws DriverException { |
|
269 |
try { |
|
270 |
return wfsDriver.getFullExtent(); |
|
271 |
} catch (IOException e) { |
|
272 |
throw new DriverException(e.toString()); |
|
273 |
} |
|
274 |
} |
|
275 |
} |
|
0 | 276 |
Also available in: Unified diff