svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / wfs / WFSDataSourceAdapter.java @ 1906
History | View | Annotate | Download (4.15 KB)
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; |
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.util.ArrayList; |
48 |
import java.util.HashMap; |
49 |
import java.util.Map; |
50 |
|
51 |
import org.exolab.castor.xml.ValidationException; |
52 |
import org.geotools.data.DataStore; |
53 |
import org.geotools.data.wfs.WFSDataStore; |
54 |
import org.geotools.data.wfs.WFSDataStoreFactory; |
55 |
|
56 |
import com.iver.cit.gvsig.gui.wms.LayerInfo; |
57 |
import com.iver.cit.gvsig.gui.wms.WizardData; |
58 |
import com.iver.cit.gvsig.gui.wms.WizardDataSource; |
59 |
import com.iver.wmsclient.UnsupportedVersionException; |
60 |
import com.iver.wmsclient.wms_1_0_0.capabilities.Format; |
61 |
import com.iver.wmsclient.wms_1_0_0.capabilities.Layer; |
62 |
import com.iver.wmsclient.wms_1_0_0.capabilities.Name; |
63 |
import com.iver.wmsclient.wms_1_0_0.capabilities.SRS; |
64 |
/**
|
65 |
* Adaptador del dataSource.
|
66 |
*
|
67 |
* @author Vicente Caballero Navarro
|
68 |
*/
|
69 |
public class WFSDataSourceAdapter implements WizardDataSource { |
70 |
private String urlS=null;//"http://localhost:8080/geoserver/wfs"; |
71 |
private String versionS=null;//"version=1.0.0"; |
72 |
private String requestS=null;//"request=getcapabilities"; |
73 |
private String serviceS=null;//"service=wfs"; |
74 |
private String userS=null;//"admin"; |
75 |
private String pwdS=null;//"geoserver"; |
76 |
private String[] layersS; |
77 |
private boolean protocolS=true; |
78 |
private int numFeaturesS=100; |
79 |
private int timeoutS=10000; |
80 |
|
81 |
public void setData(String user,String pwd,boolean protocol,int numFeatures,int timeout){ |
82 |
userS=user; |
83 |
pwdS=pwd; |
84 |
protocolS=protocol; |
85 |
numFeaturesS=numFeatures; |
86 |
timeoutS=timeout; |
87 |
} |
88 |
public WizardData detalles(URL host)throws IllegalStateException, |
89 |
ValidationException, UnsupportedVersionException, IOException{
|
90 |
|
91 |
DataStore ds=null;
|
92 |
URL url=host;
|
93 |
//int timeout=10000;
|
94 |
//boolean protocol=true;
|
95 |
|
96 |
Map m = new HashMap(); |
97 |
m.put(WFSDataStoreFactory.URL.key,url); |
98 |
m.put(WFSDataStoreFactory.TIMEOUT.key,new Integer(timeoutS)); |
99 |
m.put(WFSDataStoreFactory.PROTOCOL.key,new Boolean(protocolS)); |
100 |
m.put(WFSDataStoreFactory.PASSWORD.key,pwdS); |
101 |
m.put(WFSDataStoreFactory.USERNAME.key,userS); |
102 |
m.put(WFSDataStoreFactory.BUFFER_SIZE.key,new Integer(numFeaturesS)); |
103 |
try {
|
104 |
ds = (new WFSDataStoreFactory()).createNewDataStore(m);
|
105 |
} catch (IOException e) { |
106 |
e.printStackTrace(); |
107 |
} |
108 |
String[] names=null; |
109 |
try {
|
110 |
names = ds.getTypeNames(); |
111 |
} catch (IOException e1) { |
112 |
e1.printStackTrace(); |
113 |
} |
114 |
//System.out.println("Capas :");
|
115 |
WizardData data = new WizardData();
|
116 |
LayerInfo root = new LayerInfo();
|
117 |
root.text = "Capas";//l.getTitle().getContent(); |
118 |
root.name = "Nombre";//name.getContent(); |
119 |
for (int i=0;i<names.length;i++){ |
120 |
System.out.println("Capa "+i+" : "+names[i]); |
121 |
LayerInfo hijo = new LayerInfo();
|
122 |
hijo.text = names[i];//l.getTitle().getContent();
|
123 |
hijo.name = names[i];//name.getContent();
|
124 |
root.hijos.add(hijo); |
125 |
|
126 |
|
127 |
} |
128 |
data.setLayer(root); |
129 |
return data;
|
130 |
|
131 |
} |
132 |
|
133 |
public Rectangle2D getBoundingBox(String[] layerName, String srs) { |
134 |
return null; |
135 |
} |
136 |
|
137 |
} |