Revision 4911 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/fmap/drivers/wfs/FMapWFSDriver.java
FMapWFSDriver.java | ||
---|---|---|
5 | 5 |
import java.net.URL; |
6 | 6 |
import java.util.Hashtable; |
7 | 7 |
import java.util.Iterator; |
8 |
import java.util.Set; |
|
8 | 9 |
import java.util.Vector; |
9 | 10 |
|
10 | 11 |
import org.gvsig.remoteClient.wfs.WFSClient; |
12 |
import org.gvsig.remoteClient.wfs.WFSFeature; |
|
11 | 13 |
import org.gvsig.remoteClient.wfs.WFSProtocolHandler.ServiceInformation; |
12 | 14 |
|
13 | 15 |
import com.iver.cit.gvsig.fmap.DriverException; |
... | ... | |
60 | 62 |
* |
61 | 63 |
* $Id$ |
62 | 64 |
* $Log$ |
63 |
* Revision 1.1 2006-04-19 12:50:16 jorpiell |
|
65 |
* Revision 1.2 2006-04-20 16:38:24 jorpiell |
|
66 |
* Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature(). |
|
67 |
* |
|
68 |
* Revision 1.1 2006/04/19 12:50:16 jorpiell |
|
64 | 69 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor |
65 | 70 |
* |
66 | 71 |
* |
... | ... | |
70 | 75 |
*/ |
71 | 76 |
public class FMapWFSDriver implements WFSDriver{ |
72 | 77 |
private WFSClient client; |
73 |
private WFSLayerNode fmapRootLayer; |
|
78 |
private WFSLayerNode[] featuresList; |
|
79 |
private Hashtable features; |
|
74 | 80 |
|
75 | 81 |
/* |
76 | 82 |
* (non-Javadoc) |
... | ... | |
82 | 88 |
getClient(server).connect(); |
83 | 89 |
} catch (Exception e) { |
84 | 90 |
throw new WFSException(e); |
85 |
} |
|
86 |
|
|
87 |
} |
|
88 |
|
|
91 |
} |
|
92 |
} |
|
89 | 93 |
|
90 | 94 |
/** |
91 | 95 |
* Devuelve WFSClient a partir de su URL. |
... | ... | |
103 | 107 |
if (client == null) { |
104 | 108 |
client = new WFSClient(url.toString()); |
105 | 109 |
} |
106 |
|
|
107 | 110 |
return client; |
108 | 111 |
} |
109 | 112 |
|
... | ... | |
132 | 135 |
} |
133 | 136 |
|
134 | 137 |
/** |
138 |
* Returns an array of WFSLayerNode's with the descriptors of |
|
139 |
* all features (retrieved using the getCapabilities operation) |
|
140 |
* @return WFSLayerNode[] |
|
141 |
*/ |
|
142 |
public WFSLayerNode[] getLayerList(){ |
|
143 |
if (features == null) { |
|
144 |
features = new Hashtable(); |
|
145 |
Hashtable wfsFeatures = client.getFeatures(); |
|
146 |
|
|
147 |
Iterator keys = wfsFeatures.keySet().iterator(); |
|
148 |
featuresList = new WFSLayerNode[wfsFeatures.size()]; |
|
149 |
|
|
150 |
for (int i=0 ; i<wfsFeatures.size() ; i++){ |
|
151 |
WFSLayerNode lyr = new WFSLayerNode(); |
|
152 |
WFSFeature feature = (WFSFeature)wfsFeatures.get(keys.next()); |
|
153 |
|
|
154 |
lyr.setName(feature.getName()); |
|
155 |
lyr.setTitle(feature.getTitle()); |
|
156 |
lyr.setAbstract(feature.getAbstract()); |
|
157 |
lyr.setFields(feature.getFields()); |
|
158 |
|
|
159 |
featuresList[i] = lyr; |
|
160 |
features.put(lyr.getName(), lyr); |
|
161 |
} |
|
162 |
} |
|
163 |
return featuresList; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* Returns all the feature information retrieved using a |
|
168 |
* describeFeatureTypeOpearion |
|
169 |
* @param layerName |
|
170 |
* Feature name |
|
171 |
* @return |
|
172 |
*/ |
|
173 |
public WFSLayerNode getLayerInfo(String layerName){ |
|
174 |
WFSLayerNode lyr = (WFSLayerNode)features.get(layerName); |
|
175 |
if (lyr.getFields().size() == 0){ |
|
176 |
try { |
|
177 |
describeFeatureType(layerName); |
|
178 |
WFSFeature feature = (WFSFeature) client.getFeatures().get(layerName); |
|
179 |
lyr.setFields(feature.getFields()); |
|
180 |
} catch (WFSException e) { |
|
181 |
// The feature doesn't has fields |
|
182 |
e.printStackTrace(); |
|
183 |
} |
|
184 |
} |
|
185 |
return lyr; |
|
186 |
} |
|
187 |
|
|
188 |
|
|
189 |
/** |
|
135 | 190 |
* @return The title of the service offered by the WMS server. |
136 | 191 |
*/ |
137 | 192 |
public String getServiceTitle() { |
... | ... | |
168 | 223 |
} |
169 | 224 |
|
170 | 225 |
/** |
171 |
* Returns the feature list |
|
172 |
* @return Features vector |
|
173 |
*/ |
|
174 |
public Vector getFeatures(){ |
|
175 |
return client.getFeatures(); |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 | 226 |
* |
180 | 227 |
* @return the host |
181 | 228 |
*/ |
... | ... | |
189 | 236 |
public String getVersion() { |
190 | 237 |
return client.getVersion(); |
191 | 238 |
} |
239 |
|
|
240 |
/* |
|
241 |
* (non-Javadoc) |
|
242 |
* @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#describeFeatureType(java.lang.String) |
|
243 |
*/ |
|
244 |
public void describeFeatureType(String featureType) throws WFSException { |
|
245 |
client.describeFeatureType(null,featureType); |
|
246 |
} |
|
192 | 247 |
|
193 | 248 |
|
194 | 249 |
} |
Also available in: Unified diff