Revision 2314
tags/Root_gvSIG_WFS04/extensions/extWFS/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>gvSIG_JDBC</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
|
0 | 18 |
tags/Root_gvSIG_WFS04/extensions/extWFS/config/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="com.iver.cit.gvsig" /> |
|
4 |
<libraries library-dir="."/> |
|
5 |
<extensions> |
|
6 |
<extension class-name="com.iver.cit.gvsig.wfs.ExtWFS" |
|
7 |
description="Support to access WFS" |
|
8 |
active="true" |
|
9 |
priority="1"> |
|
10 |
</extension> |
|
11 |
</extensions> |
|
12 |
</plugin-config> |
|
0 | 13 |
tags/Root_gvSIG_WFS04/extensions/extWFS/src/com/iver/cit/gvsig/wfs/ExtWFS.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 22-jun-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.wfs; |
|
45 |
|
|
46 |
import com.iver.andami.plugins.Extension; |
|
47 |
import com.iver.cit.gvsig.AddLayer; |
|
48 |
import com.iver.cit.gvsig.wfs.gui.wfswizard.WizardWFS; |
|
49 |
|
|
50 |
public class ExtWFS implements Extension { |
|
51 |
|
|
52 |
public void inicializar() { |
|
53 |
System.out.println("A?ado Wizard WFS."); |
|
54 |
AddLayer.addWizard(WizardWFS.class); |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
public void execute(String actionCommand) { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
public boolean isEnabled() { |
|
64 |
// TODO Auto-generated method stub |
|
65 |
return false; |
|
66 |
} |
|
67 |
|
|
68 |
public boolean isVisible() { |
|
69 |
// TODO Auto-generated method stub |
|
70 |
return false; |
|
71 |
} |
|
72 |
|
|
73 |
} |
|
0 | 74 |
tags/Root_gvSIG_WFS04/extensions/extWFS/src/com/iver/cit/gvsig/wfs/gui/wfswizard/WizardWFS.java | ||
---|---|---|
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 |
/* |
|
42 |
* Created on 23-abr-2004 |
|
43 |
* |
|
44 |
* To change the template for this generated file go to |
|
45 |
* Window>Preferences>Java>Code Generation>Code and Comments |
|
46 |
*/ |
|
47 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
48 |
* |
|
49 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
50 |
* |
|
51 |
* This program is free software; you can redistribute it and/or |
|
52 |
* modify it under the terms of the GNU General Public License |
|
53 |
* as published by the Free Software Foundation; either version 2 |
|
54 |
* of the License, or (at your option) any later version. |
|
55 |
* |
|
56 |
* This program is distributed in the hope that it will be useful, |
|
57 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
58 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
59 |
* GNU General Public License for more details. |
|
60 |
* |
|
61 |
* You should have received a copy of the GNU General Public License |
|
62 |
* along with this program; if not, write to the Free Software |
|
63 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
64 |
* |
|
65 |
* For more information, contact: |
|
66 |
* |
|
67 |
* Generalitat Valenciana |
|
68 |
* Conselleria d'Infraestructures i Transport |
|
69 |
* Av. Blasco Ib??ez, 50 |
|
70 |
* 46010 VALENCIA |
|
71 |
* SPAIN |
|
72 |
* |
|
73 |
* +34 963862235 |
|
74 |
* gvsig@gva.es |
|
75 |
* www.gvsig.gva.es |
|
76 |
* |
|
77 |
* or |
|
78 |
* |
|
79 |
* IVER T.I. S.A |
|
80 |
* Salamanca 50 |
|
81 |
* 46005 Valencia |
|
82 |
* Spain |
|
83 |
* |
|
84 |
* +34 963163400 |
|
85 |
* dac@iver.es |
|
86 |
*/ |
|
87 |
package com.iver.cit.gvsig.wfs.gui.wfswizard; |
|
88 |
|
|
89 |
import java.awt.BorderLayout; |
|
90 |
import java.awt.Component; |
|
91 |
import java.io.IOException; |
|
92 |
import java.net.MalformedURLException; |
|
93 |
import java.net.URL; |
|
94 |
import java.util.ArrayList; |
|
95 |
|
|
96 |
import javax.swing.DefaultComboBoxModel; |
|
97 |
import javax.swing.JButton; |
|
98 |
import javax.swing.JLabel; |
|
99 |
import javax.swing.JOptionPane; |
|
100 |
import javax.swing.JPanel; |
|
101 |
import javax.swing.JPasswordField; |
|
102 |
import javax.swing.JRadioButton; |
|
103 |
import javax.swing.JScrollPane; |
|
104 |
import javax.swing.JTextField; |
|
105 |
import javax.swing.ListModel; |
|
106 |
import javax.swing.tree.DefaultTreeSelectionModel; |
|
107 |
import javax.swing.tree.TreePath; |
|
108 |
import javax.swing.tree.TreeSelectionModel; |
|
109 |
|
|
110 |
import org.apache.log4j.Logger; |
|
111 |
import org.cresques.cts.IProjection; |
|
112 |
import org.cresques.cts.ProjectionPool; |
|
113 |
import org.exolab.castor.xml.ValidationException; |
|
114 |
|
|
115 |
import com.iver.andami.PluginServices; |
|
116 |
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSDriver; |
|
117 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
118 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
119 |
import com.iver.cit.gvsig.gui.WizardPanel; |
|
120 |
import com.iver.cit.gvsig.gui.wizards.LayerInfo; |
|
121 |
import com.iver.cit.gvsig.gui.wizards.LayerListModel; |
|
122 |
import com.iver.cit.gvsig.gui.wizards.LayerTreeModel; |
|
123 |
import com.iver.cit.gvsig.gui.wizards.WizardData; |
|
124 |
import com.iver.cit.gvsig.gui.wizards.WizardDataSource; |
|
125 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
|
126 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
|
127 |
import com.iver.utiles.NotExistInXMLEntity; |
|
128 |
import com.iver.utiles.XMLEntity; |
|
129 |
import com.iver.utiles.swing.JComboBox; |
|
130 |
import com.iver.wmsclient.UnsupportedVersionException; |
|
131 |
/** |
|
132 |
* DOCUMENT ME! |
|
133 |
* |
|
134 |
* @author Vicente Caballero Navarro |
|
135 |
*/ |
|
136 |
public class WizardWFS extends WizardPanel { |
|
137 |
private static Logger logger = Logger.getLogger(WizardWFS.class.getName()); |
|
138 |
private int page = 0; |
|
139 |
private boolean conectado = false; |
|
140 |
private javax.swing.JPanel jContentPane = null; |
|
141 |
private JComboBox cmbHost = null; |
|
142 |
private javax.swing.JPanel panelPage1 = null; |
|
143 |
private LayerListModel selectedLayersModel = new LayerListModel(); |
|
144 |
private javax.swing.JPanel jPanel1 = null; |
|
145 |
private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
|
146 |
private WizardDataSource dataSource; |
|
147 |
private JPanel jPanel = null; |
|
148 |
private JLabel jLabel = null; |
|
149 |
private JTextField jTxtUser = null; |
|
150 |
private JLabel jLabel1 = null; |
|
151 |
private JPasswordField jTxtPassword = null; |
|
152 |
private JRadioButton jRadioButton = null; |
|
153 |
private JRadioButton jRadioButton1 = null; |
|
154 |
private JTextField jTxtnumfeatures = null; |
|
155 |
private JLabel jLabel2 = null; |
|
156 |
private JLabel jLabel3 = null; |
|
157 |
private JTextField jTxttimeout = null; |
|
158 |
private JButton jButton = null; |
|
159 |
private JButton jButton1 = null; |
|
160 |
private JScrollPane jScrollPane = null; |
|
161 |
private javax.swing.JTree treeLayers1 = null; |
|
162 |
private JPanel panePage2 = null; |
|
163 |
private String versionS="version=1.0.0"; |
|
164 |
private String requestS="request=getcapabilities"; |
|
165 |
private String serviceS="service=wfs"; |
|
166 |
private LayerListModel modelo; |
|
167 |
/** |
|
168 |
* This is the default constructor |
|
169 |
*/ |
|
170 |
public WizardWFS() { |
|
171 |
super(); |
|
172 |
initialize(); |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* This method initializes this |
|
177 |
*/ |
|
178 |
private void initialize() { |
|
179 |
setTabName("WFS"); |
|
180 |
this.setSize(510, 311); |
|
181 |
this.setLayout(null); |
|
182 |
this.setPreferredSize(new java.awt.Dimension(750, 320)); |
|
183 |
this.setVisible(true); |
|
184 |
this.add(getPanePage2(), null); |
|
185 |
this.add(getJButton1(), null); |
|
186 |
this.add(getJButton(), null); |
|
187 |
this.add(getPanelPage1(), null); |
|
188 |
//JRadioButtonMenuItem jrmi=new JRadioButtonMenuItem(); |
|
189 |
//jrmi.add(getJRadioButton()); |
|
190 |
//jrmi.add(getJRadioButton1()); |
|
191 |
//this.add(jrmi); |
|
192 |
listenerSupport.callStateChanged(true); |
|
193 |
// activarVisualizarBotones(); |
|
194 |
} |
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
/** |
|
199 |
* DOCUMENT ME! |
|
200 |
* |
|
201 |
* @param host DOCUMENT ME! |
|
202 |
*/ |
|
203 |
private void addHost(String host) { |
|
204 |
host = host.trim(); |
|
205 |
|
|
206 |
DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost() |
|
207 |
.getModel(); |
|
208 |
|
|
209 |
if (model.getIndexOf(host) < 0) { |
|
210 |
model.addElement(host); |
|
211 |
|
|
212 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
213 |
XMLEntity xml = ps.getPersistentXML(); |
|
214 |
|
|
215 |
try { |
|
216 |
String[] servers = xml.getStringArrayProperty("wms-servers"); |
|
217 |
String[] newServers = new String[servers.length + 1]; |
|
218 |
System.arraycopy(servers, 0, newServers, 0, servers.length); |
|
219 |
newServers[servers.length] = host; |
|
220 |
xml.putProperty("wfs-servers", newServers); |
|
221 |
} catch (NotExistInXMLEntity e) { |
|
222 |
xml.putProperty("wfs-servers", new String[] { host }); |
|
223 |
} |
|
224 |
|
|
225 |
ps.setPersistentXML(xml); |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
/** |
|
232 |
* This method initializes txtHost |
|
233 |
* |
|
234 |
* @return javax.swing.JTextField |
|
235 |
*/ |
|
236 |
private javax.swing.JComboBox getTxtHost() { |
|
237 |
if (cmbHost == null) { |
|
238 |
cmbHost = new JComboBox(); |
|
239 |
cmbHost.setModel(new DefaultComboBoxModel()); |
|
240 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
|
241 |
cmbHost.setEditable(true); |
|
242 |
|
|
243 |
XMLEntity xml = PluginServices.getPluginServices(this) |
|
244 |
.getPersistentXML(); |
|
245 |
if (xml == null) |
|
246 |
xml = new XMLEntity(); |
|
247 |
String[] servers = null; |
|
248 |
if (!xml.contains("wfs-servers")) { |
|
249 |
servers = new String[1]; |
|
250 |
servers[0] = "http://localhost:8080/geoserver/wfs"; |
|
251 |
|
|
252 |
xml.putProperty("wfs-servers", servers); |
|
253 |
} |
|
254 |
|
|
255 |
try { |
|
256 |
servers = xml.getStringArrayProperty("wfs-servers"); |
|
257 |
|
|
258 |
for (int i = 0; i < servers.length; i++) { |
|
259 |
((DefaultComboBoxModel) cmbHost.getModel()).addElement(servers[i]); |
|
260 |
} |
|
261 |
} catch (NotExistInXMLEntity e) { |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
return cmbHost; |
|
266 |
} |
|
267 |
|
|
268 |
/** |
|
269 |
* This method initializes panelPage1 |
|
270 |
* |
|
271 |
* @return javax.swing.JPanel |
|
272 |
*/ |
|
273 |
private javax.swing.JPanel getPanelPage1() { |
|
274 |
if (panelPage1 == null) { |
|
275 |
panelPage1 = new javax.swing.JPanel(); |
|
276 |
panelPage1.setLayout(new BorderLayout()); |
|
277 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
|
278 |
panelPage1.setVisible(true); |
|
279 |
panelPage1.setBounds(15, 5, 480, 262); |
|
280 |
panelPage1.add(getJPanel1(), java.awt.BorderLayout.NORTH); |
|
281 |
panelPage1.add(getJPanel(), java.awt.BorderLayout.CENTER); |
|
282 |
} |
|
283 |
|
|
284 |
return panelPage1; |
|
285 |
} |
|
286 |
|
|
287 |
/** |
|
288 |
* This method initializes jPanel1 |
|
289 |
* |
|
290 |
* @return javax.swing.JPanel |
|
291 |
*/ |
|
292 |
private javax.swing.JPanel getJPanel1() { |
|
293 |
if (jPanel1 == null) { |
|
294 |
jPanel1 = new javax.swing.JPanel(); |
|
295 |
jPanel1.add(getTxtHost(), null); |
|
296 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
|
297 |
null, PluginServices.getText(this, "Cadena de conexi?n"), |
|
298 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
299 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
300 |
} |
|
301 |
|
|
302 |
return jPanel1; |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* DOCUMENT ME! |
|
307 |
* |
|
308 |
* @param listener |
|
309 |
*/ |
|
310 |
public void addWizardListener(WizardListener listener) { |
|
311 |
listenerSupport.addWizardListener(listener); |
|
312 |
} |
|
313 |
|
|
314 |
/** |
|
315 |
* DOCUMENT ME! |
|
316 |
* |
|
317 |
* @param listener |
|
318 |
*/ |
|
319 |
public void removeWizardListener(WizardListener listener) { |
|
320 |
listenerSupport.removeWizardListener(listener); |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
324 |
* DOCUMENT ME! |
|
325 |
* |
|
326 |
* @return |
|
327 |
*/ |
|
328 |
public WizardDataSource getDataSource() { |
|
329 |
return dataSource; |
|
330 |
} |
|
331 |
|
|
332 |
/** |
|
333 |
* DOCUMENT ME! |
|
334 |
* |
|
335 |
* @param source |
|
336 |
*/ |
|
337 |
public void setDataSource(WizardDataSource source) { |
|
338 |
dataSource = source; |
|
339 |
} |
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
public String getUrlConnect() { |
|
346 |
return cmbHost.getModel().getSelectedItem().toString(); |
|
347 |
} |
|
348 |
public String getUser() { |
|
349 |
return jTxtUser.getText(); |
|
350 |
} |
|
351 |
public String getPassword() { |
|
352 |
return jTxtPassword.getText(); |
|
353 |
} |
|
354 |
public String getLayerName(){ |
|
355 |
return getLayers()[0];//getLstSelectedLayers().getModel().toString(); |
|
356 |
} |
|
357 |
public String[] getLayers(){ |
|
358 |
ListModel listModel= modelo; |
|
359 |
String[] layers=new String[listModel.getSize()]; |
|
360 |
for (int i=0;i<listModel.getSize();i++){ |
|
361 |
layers[i]=listModel.getElementAt(i).toString(); |
|
362 |
} |
|
363 |
return layers; |
|
364 |
} |
|
365 |
public WFSDriver getWFSDriver(){ |
|
366 |
return null;// new FMapWFSDriver(); |
|
367 |
} |
|
368 |
public URL getHost(){ |
|
369 |
String urlS="http://localhost:8080/geoserver/wfs"; |
|
370 |
String versionS="version=1.0.0"; |
|
371 |
String requestS="request=getcapabilities"; |
|
372 |
String serviceS="service=wfs"; |
|
373 |
URL url=null; |
|
374 |
try { |
|
375 |
url = new URL(urlS+"?"+versionS+"&"+requestS+"&"+serviceS); |
|
376 |
} catch (MalformedURLException e) { |
|
377 |
e.printStackTrace(); |
|
378 |
} |
|
379 |
return url; |
|
380 |
} |
|
381 |
public IProjection getProjection(){ |
|
382 |
return ProjectionPool.get("EPSG:23030"); |
|
383 |
} |
|
384 |
/** |
|
385 |
* This method initializes jPanel |
|
386 |
* |
|
387 |
* @return javax.swing.JPanel |
|
388 |
*/ |
|
389 |
private JPanel getJPanel() { |
|
390 |
if (jPanel == null) { |
|
391 |
jLabel3 = new JLabel(); |
|
392 |
jLabel3.setBounds(241, 157, 121, 18); |
|
393 |
jLabel3.setText("Timeout"); |
|
394 |
jLabel2 = new JLabel(); |
|
395 |
jLabel2.setBounds(241, 129, 121, 18); |
|
396 |
jLabel2.setText("N. Features buffer"); |
|
397 |
jPanel = new JPanel(); |
|
398 |
jLabel = new JLabel(); |
|
399 |
jLabel1 = new JLabel(); |
|
400 |
jPanel.setLayout(null); |
|
401 |
jLabel.setText("Usuario:"); |
|
402 |
jLabel.setName("jLabel"); |
|
403 |
jLabel.setSize(80, 19); |
|
404 |
jLabel.setLocation(151, 12); |
|
405 |
jLabel1.setBounds(149, 41, 82, 19); |
|
406 |
jLabel1.setText("Contrase?a:"); |
|
407 |
jPanel.add(getJTxttimeout(), null); |
|
408 |
jPanel.add(jLabel3, null); |
|
409 |
jPanel.add(jLabel2, null); |
|
410 |
jPanel.add(getJTxtnumfeatures(), null); |
|
411 |
jPanel.add(getJRadioButton1(), null); |
|
412 |
jPanel.add(getJRadioButton(), null); |
|
413 |
jPanel.add(jLabel, null); |
|
414 |
jPanel.add(getJTxtUser(), null); |
|
415 |
jPanel.add(jLabel1, null); |
|
416 |
jPanel.add(getJTxtPassword(), null); |
|
417 |
} |
|
418 |
return jPanel; |
|
419 |
} |
|
420 |
/** |
|
421 |
* This method initializes jTextField |
|
422 |
* |
|
423 |
* @return javax.swing.JTextField |
|
424 |
*/ |
|
425 |
private JTextField getJTxtUser() { |
|
426 |
if (jTxtUser == null) { |
|
427 |
jTxtUser = new JTextField(); |
|
428 |
jTxtUser.setName("jTextField"); |
|
429 |
jTxtUser.setColumns(0); |
|
430 |
jTxtUser.setBounds(241, 12, 169, 19); |
|
431 |
jTxtUser.addFocusListener(new java.awt.event.FocusListener() { |
|
432 |
public void focusLost(java.awt.event.FocusEvent e) { |
|
433 |
listenerSupport.callStateChanged(true); |
|
434 |
System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
|
435 |
} |
|
436 |
public void focusGained(java.awt.event.FocusEvent e) {} |
|
437 |
}); |
|
438 |
} |
|
439 |
return jTxtUser; |
|
440 |
} |
|
441 |
/** |
|
442 |
* This method initializes jPasswordField |
|
443 |
* |
|
444 |
* @return javax.swing.JPasswordField |
|
445 |
*/ |
|
446 |
private JPasswordField getJTxtPassword() { |
|
447 |
if (jTxtPassword == null) { |
|
448 |
jTxtPassword = new JPasswordField(); |
|
449 |
jTxtPassword.setBounds(241, 39, 169, 20); |
|
450 |
} |
|
451 |
return jTxtPassword; |
|
452 |
} |
|
453 |
|
|
454 |
/** |
|
455 |
* This method initializes jRadioButton |
|
456 |
* |
|
457 |
* @return javax.swing.JRadioButton |
|
458 |
*/ |
|
459 |
private JRadioButton getJRadioButton() { |
|
460 |
if (jRadioButton == null) { |
|
461 |
jRadioButton = new JRadioButton(); |
|
462 |
jRadioButton.setBounds(241, 73, 121, 18); |
|
463 |
jRadioButton.setText("GET"); |
|
464 |
jRadioButton.setSelected(true); |
|
465 |
} |
|
466 |
return jRadioButton; |
|
467 |
} |
|
468 |
|
|
469 |
/** |
|
470 |
* This method initializes jRadioButton1 |
|
471 |
* |
|
472 |
* @return javax.swing.JRadioButton |
|
473 |
*/ |
|
474 |
private JRadioButton getJRadioButton1() { |
|
475 |
if (jRadioButton1 == null) { |
|
476 |
jRadioButton1 = new JRadioButton(); |
|
477 |
jRadioButton1.setBounds(241, 101, 121, 18); |
|
478 |
jRadioButton1.setText("POST"); |
|
479 |
} |
|
480 |
return jRadioButton1; |
|
481 |
} |
|
482 |
|
|
483 |
/** |
|
484 |
* This method initializes jTextField |
|
485 |
* |
|
486 |
* @return javax.swing.JTextField |
|
487 |
*/ |
|
488 |
private JTextField getJTxtnumfeatures() { |
|
489 |
if (jTxtnumfeatures == null) { |
|
490 |
jTxtnumfeatures = new JTextField(); |
|
491 |
jTxtnumfeatures.setBounds(372, 129, 38, 18); |
|
492 |
jTxtnumfeatures.setText("100"); |
|
493 |
} |
|
494 |
return jTxtnumfeatures; |
|
495 |
} |
|
496 |
|
|
497 |
/** |
|
498 |
* This method initializes jTextField1 |
|
499 |
* |
|
500 |
* @return javax.swing.JTextField |
|
501 |
*/ |
|
502 |
private JTextField getJTxttimeout() { |
|
503 |
if (jTxttimeout == null) { |
|
504 |
jTxttimeout = new JTextField(); |
|
505 |
jTxttimeout.setBounds(371, 157, 39, 18); |
|
506 |
jTxttimeout.setText("10000"); |
|
507 |
} |
|
508 |
return jTxttimeout; |
|
509 |
} |
|
510 |
|
|
511 |
/** |
|
512 |
* This method initializes jButton |
|
513 |
* |
|
514 |
* @return javax.swing.JButton |
|
515 |
*/ |
|
516 |
private JButton getJButton() { |
|
517 |
if (jButton == null) { |
|
518 |
jButton = new JButton(); |
|
519 |
jButton.setBounds(108, 275, 94, 22); |
|
520 |
jButton.setText(PluginServices.getText(this, "anterior")); |
|
521 |
jButton.setEnabled(false); |
|
522 |
jButton.addActionListener(new java.awt.event.ActionListener() { |
|
523 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
524 |
page--; |
|
525 |
//getPanelPage1().setVisible(true); |
|
526 |
//getPanePage2().setVisible(false); |
|
527 |
activarVisualizarBotones(); |
|
528 |
conectado=true; |
|
529 |
} |
|
530 |
}); |
|
531 |
} |
|
532 |
return jButton; |
|
533 |
} |
|
534 |
|
|
535 |
/** |
|
536 |
* This method initializes jButton1 |
|
537 |
* |
|
538 |
* @return javax.swing.JButton |
|
539 |
*/ |
|
540 |
private JButton getJButton1() { |
|
541 |
if (jButton1 == null) { |
|
542 |
jButton1 = new JButton(); |
|
543 |
jButton1.setBounds(306, 275, 94, 22); |
|
544 |
jButton1.setText(PluginServices.getText(this, "siguiente")); |
|
545 |
jButton1.addActionListener(new java.awt.event.ActionListener() { |
|
546 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
547 |
try{ |
|
548 |
page++; |
|
549 |
rellenarControles(); |
|
550 |
//getPanelPage1().setVisible(false); |
|
551 |
//getPanePage2().setVisible(true); |
|
552 |
activarVisualizarBotones(); |
|
553 |
} catch (Exception e1) { |
|
554 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"Servidor WFS no v?lido."); |
|
555 |
page--; |
|
556 |
listenerSupport.callError(e1); |
|
557 |
} |
|
558 |
} |
|
559 |
}); |
|
560 |
} |
|
561 |
return jButton1; |
|
562 |
} |
|
563 |
/** |
|
564 |
* DOCUMENT ME! |
|
565 |
*/ |
|
566 |
private void activarVisualizarBotones() { |
|
567 |
if (page == 0) { |
|
568 |
getPanePage2().setVisible(false); |
|
569 |
getPanelPage1().setVisible(true); |
|
570 |
|
|
571 |
getJButton().setEnabled(false); |
|
572 |
getJButton1().setVisible(true); |
|
573 |
|
|
574 |
if (conectado) { |
|
575 |
getJButton1().setEnabled(true); |
|
576 |
} else { |
|
577 |
getJButton1().setEnabled(false); |
|
578 |
} |
|
579 |
} else if (page == 1) { |
|
580 |
//rellenarControles(); |
|
581 |
|
|
582 |
getPanelPage1().setVisible(false); |
|
583 |
getPanePage2().setVisible(true); |
|
584 |
getJButton1().setVisible(false); |
|
585 |
getJButton().setEnabled(true); |
|
586 |
|
|
587 |
listenerSupport.callStateChanged(true); |
|
588 |
|
|
589 |
/*if ((getLstSRSs().getSelectedIndex() != -1) && |
|
590 |
(getLstFormats1().getSelectedIndex() != -1) && |
|
591 |
(getLstSelectedLayers().getModel().getSize() > 0)) { |
|
592 |
listenerSupport.callStateChanged(true); |
|
593 |
} else { |
|
594 |
listenerSupport.callStateChanged(false); |
|
595 |
} |
|
596 |
*/ |
|
597 |
if (getTreeLayers1().getSelectionCount() > 0) { |
|
598 |
LayerInfo nodo = (LayerInfo) getTreeLayers1().getSelectionPath() |
|
599 |
.getLastPathComponent(); |
|
600 |
String name = nodo.name; |
|
601 |
|
|
602 |
if (name != null) { |
|
603 |
//getBtnAdd().setEnabled(true); |
|
604 |
} else { |
|
605 |
//getBtnAdd().setEnabled(false); |
|
606 |
} |
|
607 |
} else { |
|
608 |
//getBtnAdd().setEnabled(false); |
|
609 |
} |
|
610 |
|
|
611 |
//if (getLstSelectedLayers().getSelectedIndex() != -1) { |
|
612 |
// getBtnDel().setEnabled(true); |
|
613 |
//} else { |
|
614 |
// getBtnDel().setEnabled(false); |
|
615 |
//} |
|
616 |
} |
|
617 |
} |
|
618 |
|
|
619 |
/** |
|
620 |
* This method initializes jScrollPane |
|
621 |
* |
|
622 |
* @return javax.swing.JScrollPane |
|
623 |
*/ |
|
624 |
private JScrollPane getJScrollPane() { |
|
625 |
if (jScrollPane == null) { |
|
626 |
jScrollPane = new JScrollPane(); |
|
627 |
jScrollPane.setViewportView(getTreeLayers1()); |
|
628 |
jScrollPane.setPreferredSize(new java.awt.Dimension(150,200)); |
|
629 |
} |
|
630 |
return jScrollPane; |
|
631 |
} |
|
632 |
private javax.swing.JTree getTreeLayers1() { |
|
633 |
if (treeLayers1 == null) { |
|
634 |
treeLayers1 = new javax.swing.JTree(); |
|
635 |
treeLayers1.setRootVisible(false); |
|
636 |
TreeSelectionModel tsm=new DefaultTreeSelectionModel(); |
|
637 |
tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); |
|
638 |
treeLayers1.setSelectionModel(tsm); |
|
639 |
treeLayers1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { |
|
640 |
public void valueChanged( |
|
641 |
javax.swing.event.TreeSelectionEvent e) { |
|
642 |
addLayer(); |
|
643 |
///activarVisualizarBotones(); |
|
644 |
} |
|
645 |
}); |
|
646 |
} |
|
647 |
|
|
648 |
return treeLayers1; |
|
649 |
} |
|
650 |
/** |
|
651 |
* DOCUMENT ME! |
|
652 |
*/ |
|
653 |
private void addLayer() { |
|
654 |
boolean alguno = false; |
|
655 |
|
|
656 |
TreePath[] selecciones = getTreeLayers1().getSelectionPaths(); |
|
657 |
|
|
658 |
for (int i = 0; i < selecciones.length; i++) { |
|
659 |
LayerInfo nodo = (LayerInfo) selecciones[i].getLastPathComponent(); |
|
660 |
|
|
661 |
String name = nodo.name; |
|
662 |
String text = nodo.text; |
|
663 |
|
|
664 |
//Se a?ade a la lista de layers seleccionados |
|
665 |
modelo = new LayerListModel();//(LayerListModel) lstSelectedLayers.getModel(); |
|
666 |
|
|
667 |
if (modelo.addElement(nodo)) { |
|
668 |
alguno = true; |
|
669 |
} |
|
670 |
} |
|
671 |
|
|
672 |
if (alguno) { |
|
673 |
activarVisualizarBotones(); |
|
674 |
//actualizarSRS(); |
|
675 |
} |
|
676 |
} |
|
677 |
|
|
678 |
/** |
|
679 |
* DOCUMENT ME! |
|
680 |
*/ |
|
681 |
private void delLayer() { |
|
682 |
//int[] index = lstSelectedLayers.getSelectedIndices(); |
|
683 |
|
|
684 |
ArrayList removeList = new ArrayList(); |
|
685 |
//LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel(); |
|
686 |
LayerInfo[] infos = modelo.getElements(); |
|
687 |
|
|
688 |
//for (int i = 0; i < index.length; i++) { |
|
689 |
// removeList.add(infos[index[i]]); |
|
690 |
//} |
|
691 |
|
|
692 |
modelo.delElements(removeList); |
|
693 |
//lstSelectedLayers.clearSelection(); |
|
694 |
|
|
695 |
activarVisualizarBotones(); |
|
696 |
|
|
697 |
//actualizarSRS(); |
|
698 |
} |
|
699 |
/** |
|
700 |
* DOCUMENT ME! |
|
701 |
* @throws IOException |
|
702 |
* @throws UnsupportedVersionException |
|
703 |
* @throws MalformedURLException |
|
704 |
* @throws ValidationException |
|
705 |
* @throws IllegalStateException |
|
706 |
*/ |
|
707 |
private void rellenarControles() throws IllegalStateException, ValidationException, MalformedURLException, UnsupportedVersionException, IOException { |
|
708 |
String host = cmbHost.getModel().getSelectedItem().toString(); |
|
709 |
((WFSDataSourceAdapter)dataSource).setData(getUser(),getPassword(),getProtocol(),getNumFeatures(),getTimeout()); |
|
710 |
WizardData data = dataSource.detalles(new URL(host+"?"+versionS+"&"+requestS+"&"+serviceS)); |
|
711 |
|
|
712 |
addHost(host); |
|
713 |
treeLayers1.setModel(new LayerTreeModel(data.getLayer())); |
|
714 |
conectado = true; |
|
715 |
|
|
716 |
} |
|
717 |
|
|
718 |
/** |
|
719 |
* This method initializes jPanel3 |
|
720 |
* |
|
721 |
* @return javax.swing.JPanel |
|
722 |
*/ |
|
723 |
private JPanel getPanePage2() { |
|
724 |
if (panePage2 == null) { |
|
725 |
panePage2 = new JPanel(); |
|
726 |
panePage2.setBounds(0, 2, 495, 266); |
|
727 |
panePage2.setVisible(false); |
|
728 |
panePage2.add(getJScrollPane(), null); |
|
729 |
} |
|
730 |
return panePage2; |
|
731 |
} |
|
732 |
|
|
733 |
public boolean getProtocol(){ |
|
734 |
if (getJRadioButton().isSelected()){ |
|
735 |
return true; |
|
736 |
} |
|
737 |
return false; |
|
738 |
} |
|
739 |
public int getNumFeatures(){ |
|
740 |
return Integer.parseInt(getJTxtnumfeatures().getText()); |
|
741 |
} |
|
742 |
public int getTimeout(){ |
|
743 |
return Integer.parseInt(getJTxttimeout().getText()); |
|
744 |
} |
|
745 |
public void initWizard() { |
|
746 |
setDataSource(new WFSDataSourceAdapter()); |
|
747 |
} |
|
748 |
|
|
749 |
/* (non-Javadoc) |
|
750 |
* @see com.iver.cit.gvsig.gui.WizardPanel#execute() |
|
751 |
*/ |
|
752 |
public void execute() { |
|
753 |
} |
|
754 |
|
|
755 |
/* (non-Javadoc) |
|
756 |
* @see com.iver.cit.gvsig.gui.WizardPanel#getLayer() |
|
757 |
*/ |
|
758 |
public FLayer getLayer() { |
|
759 |
WizardWFS wfs = this; |
|
760 |
String[] layers=wfs.getLayers(); |
|
761 |
if (layers.length>0) { |
|
762 |
String layerName = wfs.getLayerName(); |
|
763 |
String user = wfs.getUser(); |
|
764 |
String pwd = wfs.getPassword(); |
|
765 |
String url = wfs.getUrlConnect(); |
|
766 |
|
|
767 |
boolean protocol=wfs.getProtocol(); |
|
768 |
int numfeatures=wfs.getNumFeatures(); |
|
769 |
int timeout=wfs.getTimeout(); |
|
770 |
//String fields = wfs.getSqlFields(); |
|
771 |
//String whereClause = dbWiz.getSqlWhere(); |
|
772 |
WFSDriver driver = new WFSDriver(); |
|
773 |
try{ |
|
774 |
driver.setData(url,user,pwd,layers,protocol,numfeatures,timeout,2); |
|
775 |
}catch (IOException e) { |
|
776 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"Fallo de la conexi?n con el servidor"); |
|
777 |
return null; |
|
778 |
} |
|
779 |
return LayerFactory.createWFSLayer(layerName,driver,wfs.getHost(), |
|
780 |
wfs.getProjection()); |
|
781 |
} |
|
782 |
return null; |
|
783 |
} |
|
784 |
} |
|
0 | 785 |
tags/Root_gvSIG_WFS04/extensions/extWFS/src/com/iver/cit/gvsig/wfs/gui/wfswizard/WFSDataSourceAdapter.java | ||
---|---|---|
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.wfs.gui.wfswizard; |
|
42 |
|
|
43 |
import java.awt.geom.Rectangle2D; |
|
44 |
import java.io.IOException; |
|
45 |
import java.net.URL; |
|
46 |
import java.util.HashMap; |
|
47 |
import java.util.Map; |
|
48 |
|
|
49 |
import org.exolab.castor.xml.ValidationException; |
|
50 |
import org.geotools.data.DataStore; |
|
51 |
import org.geotools.data.wfs.WFSDataStoreFactory; |
|
52 |
|
|
53 |
import com.iver.cit.gvsig.gui.wizards.LayerInfo; |
|
54 |
import com.iver.cit.gvsig.gui.wizards.WizardData; |
|
55 |
import com.iver.cit.gvsig.gui.wizards.WizardDataSource; |
|
56 |
import com.iver.wmsclient.UnsupportedVersionException; |
|
57 |
/** |
|
58 |
* Adaptador del dataSource. |
|
59 |
* |
|
60 |
* @author Vicente Caballero Navarro |
|
61 |
*/ |
|
62 |
public class WFSDataSourceAdapter implements WizardDataSource { |
|
63 |
private String urlS=null;//"http://localhost:8080/geoserver/wfs"; |
|
64 |
private String versionS=null;//"version=1.0.0"; |
|
65 |
private String requestS=null;//"request=getcapabilities"; |
|
66 |
private String serviceS=null;//"service=wfs"; |
|
67 |
private String userS=null;//"admin"; |
|
68 |
private String pwdS=null;//"geoserver"; |
|
69 |
private String[] layersS; |
|
70 |
private boolean protocolS=true; |
|
71 |
private int numFeaturesS=100; |
|
72 |
private int timeoutS=10000; |
|
73 |
|
|
74 |
public void setData(String user,String pwd,boolean protocol,int numFeatures,int timeout){ |
|
75 |
userS=user; |
|
76 |
pwdS=pwd; |
|
77 |
protocolS=protocol; |
|
78 |
numFeaturesS=numFeatures; |
|
79 |
timeoutS=timeout; |
|
80 |
} |
|
81 |
public WizardData detalles(URL host)throws IllegalStateException, |
|
82 |
ValidationException, UnsupportedVersionException, IOException{ |
|
83 |
|
|
84 |
DataStore ds=null; |
|
85 |
URL url=host; |
|
86 |
//int timeout=10000; |
|
87 |
//boolean protocol=true; |
|
88 |
|
|
89 |
Map m = new HashMap(); |
|
90 |
m.put(WFSDataStoreFactory.URL.key,url); |
|
91 |
m.put(WFSDataStoreFactory.TIMEOUT.key,new Integer(timeoutS)); |
|
92 |
m.put(WFSDataStoreFactory.PROTOCOL.key,new Boolean(protocolS)); |
|
93 |
m.put(WFSDataStoreFactory.PASSWORD.key,pwdS); |
|
94 |
m.put(WFSDataStoreFactory.USERNAME.key,userS); |
|
95 |
m.put(WFSDataStoreFactory.BUFFER_SIZE.key,new Integer(numFeaturesS)); |
|
96 |
//try { |
|
97 |
ds = (new WFSDataStoreFactory()).createNewDataStore(m); |
|
98 |
//} catch (IOException e) { |
|
99 |
// e.printStackTrace(); |
|
100 |
//} |
|
101 |
String[] names=null; |
|
102 |
try { |
|
103 |
names = ds.getTypeNames(); |
|
104 |
} catch (IOException e1) { |
|
105 |
e1.printStackTrace(); |
|
106 |
} |
|
107 |
//System.out.println("Capas :"); |
|
108 |
WizardData data = new WizardData(); |
|
109 |
LayerInfo root = new LayerInfo(); |
|
110 |
root.text = "Capas";//l.getTitle().getContent(); |
|
111 |
root.name = "Nombre";//name.getContent(); |
|
112 |
for (int i=0;i<names.length;i++){ |
|
113 |
System.out.println("Capa "+i+" : "+names[i]); |
|
114 |
LayerInfo hijo = new LayerInfo(); |
|
115 |
hijo.text = names[i];//l.getTitle().getContent(); |
|
116 |
hijo.name = names[i];//name.getContent(); |
|
117 |
root.hijos.add(hijo); |
|
118 |
|
|
119 |
|
|
120 |
} |
|
121 |
data.setLayer(root); |
|
122 |
return data; |
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
public Rectangle2D getBoundingBox(String[] layerName, String srs) { |
|
127 |
return null; |
|
128 |
} |
|
129 |
|
|
130 |
} |
|
0 | 131 |
tags/Root_gvSIG_WFS04/extensions/extWFS/src/com/iver/cit/gvsig/fmap/drivers/wfs/WFSFeatureIterator.java | ||
---|---|---|
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.fmap.drivers.wfs; |
|
42 |
|
|
43 |
import java.io.IOException; |
|
44 |
import java.sql.SQLException; |
|
45 |
import java.util.Date; |
|
46 |
import java.util.NoSuchElementException; |
|
47 |
|
|
48 |
import org.geotools.data.FeatureReader; |
|
49 |
import org.geotools.feature.Feature; |
|
50 |
import org.geotools.feature.IllegalAttributeException; |
|
51 |
|
|
52 |
import com.hardcode.gdbms.engine.values.Value; |
|
53 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
54 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
55 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
56 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
57 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
|
58 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
59 |
|
|
60 |
public class WFSFeatureIterator implements IFeatureIterator{ |
|
61 |
//private IFeature[] features=null; |
|
62 |
private FeatureReader featureReader; |
|
63 |
//private ArrayList features; |
|
64 |
//private int index=-1; |
|
65 |
//private int pos=0; |
|
66 |
public WFSFeatureIterator(FeatureReader fr){ |
|
67 |
featureReader=fr; |
|
68 |
} |
|
69 |
/*public WFSFeatureIterator(ArrayList l){ |
|
70 |
features=l; |
|
71 |
}*/ |
|
72 |
public boolean hasNext(){ |
|
73 |
/*if (features !=null){ |
|
74 |
if (index<features.size()-1) |
|
75 |
return true; |
|
76 |
else{ |
|
77 |
index=-1; |
|
78 |
features=null; |
|
79 |
return false; |
|
80 |
} |
|
81 |
}*/ |
|
82 |
try { |
|
83 |
if (featureReader.hasNext()){ |
|
84 |
return true; |
|
85 |
}else{ |
|
86 |
featureReader.close(); |
|
87 |
|
|
88 |
return false; |
|
89 |
} |
|
90 |
} catch (IOException e) { |
|
91 |
e.printStackTrace(); |
|
92 |
} |
|
93 |
return false; |
|
94 |
} |
|
95 |
|
|
96 |
public IFeature next() throws SQLException { |
|
97 |
/* if (features !=null){ |
|
98 |
return (IFeature)features.get(++index); |
|
99 |
}*/ |
|
100 |
Feature feature=null; |
|
101 |
try { |
|
102 |
feature = featureReader.next(); |
|
103 |
} catch (NoSuchElementException e) { |
|
104 |
e.printStackTrace(); |
|
105 |
} catch (IOException e) { |
|
106 |
e.printStackTrace(); |
|
107 |
} catch (IllegalAttributeException e) { |
|
108 |
e.printStackTrace(); |
|
109 |
} |
|
110 |
Object[] attr=null; |
|
111 |
attr=feature.getAttributes(attr); |
|
112 |
Value[] values=getValues(attr); |
|
113 |
|
|
114 |
IGeometry g=ShapeFactory.createGeometry(FConverter.jts_to_java2d(feature.getDefaultGeometry())); |
|
115 |
return new com.iver.cit.gvsig.fmap.core.DefaultFeature(g,values,feature.getID()); |
|
116 |
} |
|
117 |
private Value[] getValues(Object[] attr) { |
|
118 |
Value[] values=new Value[attr.length]; |
|
119 |
for (int i=1;i<attr.length;i++){ |
|
120 |
if (attr[i]!=null){ |
|
121 |
if (attr[i] instanceof Double){ |
|
122 |
values[i]=ValueFactory.createValue(((Double)attr[i]).doubleValue()); |
|
123 |
}else if (attr[i] instanceof String){ |
|
124 |
values[i]=ValueFactory.createValue(String.valueOf(attr[i])); |
|
125 |
}else if (attr[i] instanceof Long){ |
|
126 |
values[i]=ValueFactory.createValue(((Long)attr[i]).longValue()); |
|
127 |
}else if (attr[i] instanceof Integer){ |
|
128 |
values[i]=ValueFactory.createValue(((Integer)attr[i]).intValue()); |
|
129 |
}else if (attr[i] instanceof Float){ |
|
130 |
values[i]=ValueFactory.createValue(((Float)attr[i]).floatValue()); |
|
131 |
}else if (attr[i] instanceof Short){ |
|
132 |
values[i]=ValueFactory.createValue(((Short)attr[i]).shortValue()); |
|
133 |
}else if (attr[i] instanceof Boolean){ |
|
134 |
values[i]=ValueFactory.createValue(((Boolean)attr[i]).booleanValue()); |
|
135 |
}else if (attr[i] instanceof Date){ |
|
136 |
values[i]=ValueFactory.createValue(((Date)attr[i])); |
|
137 |
} |
|
138 |
// System.out.println("class = "+attr[i].getClass()); |
|
139 |
|
|
140 |
}else{ |
|
141 |
values[i]=ValueFactory.createValue(""); |
|
142 |
} |
|
143 |
} |
|
144 |
return values; |
|
145 |
} |
|
146 |
|
|
147 |
} |
|
0 | 148 |
tags/Root_gvSIG_WFS04/extensions/extWFS/src/com/iver/cit/gvsig/fmap/drivers/wfs/WFSDriver.java | ||
---|---|---|
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.fmap.drivers.wfs; |
|
42 |
|
|
43 |
import java.awt.geom.Rectangle2D; |
|
44 |
import java.io.IOException; |
|
45 |
import java.net.MalformedURLException; |
|
46 |
import java.net.URL; |
|
47 |
import java.sql.SQLException; |
|
48 |
import java.util.ArrayList; |
|
49 |
import java.util.HashMap; |
|
50 |
import java.util.Hashtable; |
|
51 |
import java.util.Map; |
|
52 |
|
|
53 |
import org.geotools.data.DataStore; |
|
54 |
import org.geotools.data.DefaultQuery; |
|
55 |
import org.geotools.data.FeatureReader; |
|
56 |
import org.geotools.data.Query; |
|
57 |
import org.geotools.data.Transaction; |
|
58 |
import org.geotools.data.wfs.WFSDataStoreFactory; |
|
59 |
import org.geotools.feature.AttributeType; |
|
60 |
import org.geotools.filter.FidFilter; |
|
61 |
import org.geotools.filter.Filter; |
|
62 |
import org.geotools.filter.FilterFactory; |
|
63 |
|
|
64 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
|
65 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
|
66 |
import com.hardcode.gdbms.engine.values.Value; |
|
67 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
68 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
69 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
70 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
71 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
|
72 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
73 |
import com.iver.cit.gvsig.fmap.drivers.IWFSdriver; |
|
74 |
|
|
75 |
|
|
76 |
/** |
|
77 |
* Driver de WFS, utilizando DataStore de geotools. |
|
78 |
* |
|
79 |
* @author Vicente Caballero Navarro |
|
80 |
*/ |
|
81 |
public class WFSDriver implements IWFSdriver, ObjectDriver { |
|
82 |
private Rectangle2D fullExtent = null; |
|
83 |
private Rectangle2D extent = null; |
|
84 |
private DataStore ds; |
|
85 |
|
|
86 |
//private FeatureReader fr; |
|
87 |
private String urlS = "http://localhost:8080/geoserver/wfs"; |
|
88 |
private String versionS = "version=1.0.0"; |
|
89 |
private String requestS = "request=getcapabilities"; |
|
90 |
private String serviceS = "service=wfs"; |
|
91 |
private String userS = "admin"; |
|
92 |
private String pwdS = "geoserver"; |
|
93 |
private String[] layersS; |
|
94 |
private boolean protocolS = true; |
|
95 |
private int numFeaturesS = 100; |
|
96 |
private int timeoutS = 10000; |
|
97 |
private Hashtable hashRelate; |
|
98 |
|
|
99 |
///private Hashtable indexFID; |
|
100 |
protected int idFID_FieldName; |
|
101 |
private int numReg = -1; |
|
102 |
private int numField = -1; |
|
103 |
private AttributeType[] attributes; |
|
104 |
|
|
105 |
//private FeatureReader fr; |
|
106 |
///private ArrayList typeNames=new ArrayList(); |
|
107 |
private ArrayList features = new ArrayList(); |
|
108 |
|
|
109 |
/** |
|
110 |
* DOCUMENT ME! |
|
111 |
* |
|
112 |
* @return DOCUMENT ME! |
|
113 |
*/ |
|
114 |
public Rectangle2D getFullExtent() { |
|
115 |
return fullExtent; |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* DOCUMENT ME! |
|
120 |
* |
|
121 |
* @return DOCUMENT ME! |
|
122 |
*/ |
|
123 |
public int getShapeType() { |
|
124 |
return FShape.MULTI; |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* DOCUMENT ME! |
|
129 |
* |
|
130 |
* @param fids DOCUMENT ME! |
|
131 |
* |
|
132 |
* @return DOCUMENT ME! |
|
133 |
*/ |
|
134 |
private Filter createFidFilter(String[] fids) { |
|
135 |
FidFilter filter = FilterFactory.createFilterFactory().createFidFilter(); |
|
136 |
|
|
137 |
for (int i = 0; i < fids.length; i++) { |
|
138 |
filter.addFid(fids[i]); |
|
139 |
} |
|
140 |
|
|
141 |
return filter; |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* DOCUMENT ME! |
|
146 |
* |
|
147 |
* @param index DOCUMENT ME! |
|
148 |
* |
|
149 |
* @return DOCUMENT ME! |
|
150 |
*/ |
|
151 |
public IGeometry getShape(int index) { |
|
152 |
return ((IFeature) features.get(index)).getGeometry(); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* DOCUMENT ME! |
|
157 |
* |
|
158 |
* @return DOCUMENT ME! |
|
159 |
*/ |
|
160 |
public URL getHost() { |
|
161 |
try { |
|
162 |
return new URL(urlS + "?" + versionS + "&" + requestS + "&" + |
|
163 |
serviceS); |
|
164 |
} catch (MalformedURLException e) { |
|
165 |
e.printStackTrace(); |
|
166 |
} |
|
167 |
|
|
168 |
return null; |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* DOCUMENT ME! |
|
173 |
* |
|
174 |
* @param r DOCUMENT ME! |
|
175 |
* @param strEPSG DOCUMENT ME! |
|
176 |
* |
|
177 |
* @return DOCUMENT ME! |
|
178 |
* |
|
179 |
* @throws DriverException DOCUMENT ME! |
|
180 |
* @throws IOException |
|
181 |
*/ |
|
182 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) |
|
183 |
throws DriverException, IOException { |
|
184 |
WFSFeatureIterator geomIterator = null; |
|
185 |
|
|
186 |
/*if (r!=null && extent.contains(r)){ |
|
187 |
//extent=(Rectangle2D)r.clone(); |
|
188 |
return new WFSFeatureIterator(features); |
|
189 |
} |
|
190 |
*/ |
|
191 |
|
|
192 |
// ArrayList shapes=new ArrayList(); |
|
193 |
|
|
194 |
/* BBoxExpressionImpl RectangleFilter=null; |
|
195 |
try { |
|
196 |
RectangleFilter = (BBoxExpressionImpl)FilterFactoryImpl.createFilterFactory().createBBoxExpression(new Envelope(fullExtent.getX(),fullExtent.getY(),fullExtent.getMaxX(),fullExtent.getMaxY())); |
|
197 |
} catch (IllegalFilterException e2) { |
|
198 |
e2.printStackTrace(); |
|
199 |
} catch (FactoryConfigurationError e2) { |
|
200 |
e2.printStackTrace(); |
|
201 |
} |
|
202 |
*/ |
|
203 |
Query query = new DefaultQuery(layersS[0]); |
|
204 |
FeatureReader fr = null; |
|
205 |
|
|
206 |
|
|
207 |
fr = ds.getFeatureReader(query, Transaction.AUTO_COMMIT); |
|
208 |
|
|
209 |
if (numField == -1) { |
|
210 |
numField = fr.getFeatureType().getAttributeCount(); |
|
211 |
attributes = fr.getFeatureType().getAttributeTypes(); |
|
212 |
} |
|
213 |
|
|
214 |
geomIterator = new WFSFeatureIterator(fr); |
|
215 |
return geomIterator; |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* DOCUMENT ME! |
|
220 |
*/ |
|
221 |
public void close() { |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* DOCUMENT ME! |
|
226 |
* |
|
227 |
* @throws DriverException DOCUMENT ME! |
|
228 |
*/ |
|
229 |
public void open() throws DriverException { |
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* DOCUMENT ME! |
|
234 |
* |
|
235 |
* @param FID DOCUMENT ME! |
|
236 |
* |
|
237 |
* @return DOCUMENT ME! |
|
238 |
*/ |
|
239 |
public int getRowIndexByFID(IFeature FID) { |
|
240 |
int resul; |
|
241 |
Integer rowIndex = (Integer) hashRelate.get(FID.getID()); |
|
242 |
resul = rowIndex.intValue(); |
|
243 |
|
|
244 |
return resul; |
Also available in: Unified diff