svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / org / gvsig / fmap / dal / store / wfs / WFSStoreProvider.java @ 34026
History | View | Annotate | Download (22.3 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {Iver T.I.} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.dal.store.wfs; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.IOException; |
32 |
import java.util.ArrayList; |
33 |
import java.util.Iterator; |
34 |
import java.util.List; |
35 |
|
36 |
import org.cresques.cts.ICoordTrans; |
37 |
import org.cresques.cts.IProjection; |
38 |
import org.slf4j.Logger; |
39 |
import org.slf4j.LoggerFactory; |
40 |
|
41 |
import org.gvsig.fmap.crs.CRSFactory; |
42 |
import org.gvsig.fmap.dal.DALLocator; |
43 |
import org.gvsig.fmap.dal.DataManager; |
44 |
import org.gvsig.fmap.dal.DataServerExplorer; |
45 |
import org.gvsig.fmap.dal.DataStoreParameters; |
46 |
import org.gvsig.fmap.dal.DataTypes; |
47 |
import org.gvsig.fmap.dal.exception.ConnectionServerException; |
48 |
import org.gvsig.fmap.dal.exception.DataException; |
49 |
import org.gvsig.fmap.dal.exception.InitializeException; |
50 |
import org.gvsig.fmap.dal.exception.OpenException; |
51 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
52 |
import org.gvsig.fmap.dal.exception.ReadException; |
53 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
54 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
55 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
56 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
57 |
import org.gvsig.fmap.dal.feature.FeatureType; |
58 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider; |
59 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
60 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
61 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
62 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
63 |
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer; |
64 |
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorerParameters; |
65 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
66 |
import org.gvsig.fmap.dal.store.gpe.GPEStoreProvider; |
67 |
import org.gvsig.fmap.geom.Geometry; |
68 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
69 |
import org.gvsig.fmap.geom.GeometryLocator; |
70 |
import org.gvsig.fmap.geom.GeometryManager; |
71 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
72 |
import org.gvsig.fmap.geom.primitive.Envelope; |
73 |
import org.gvsig.metadata.MetadataLocator; |
74 |
import org.gvsig.metadata.MetadataManager; |
75 |
import org.gvsig.metadata.exceptions.MetadataException; |
76 |
import org.gvsig.remoteclient.ogc.OGCClientOperation; |
77 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
78 |
import org.gvsig.remoteclient.wfs.WFSClient; |
79 |
import org.gvsig.remoteclient.wfs.WFSFeature; |
80 |
import org.gvsig.remoteclient.wfs.WFSFeatureField; |
81 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
82 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
83 |
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding; |
84 |
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequestInformation; |
85 |
import org.gvsig.tools.ToolsLocator; |
86 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
87 |
import org.gvsig.tools.dynobject.DynStruct; |
88 |
import org.gvsig.tools.evaluator.EvaluatorFieldValue; |
89 |
import org.gvsig.tools.evaluator.EvaluatorFieldValueMatch; |
90 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
91 |
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator; |
92 |
import org.gvsig.xmlschema.lib.api.XMLSchemaManager; |
93 |
import org.gvsig.xmlschema.lib.api.som.IXSGeometryTypeDefinition; |
94 |
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition; |
95 |
|
96 |
|
97 |
/**
|
98 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
99 |
*/
|
100 |
public class WFSStoreProvider extends AbstractFeatureStoreProvider { |
101 |
private static final Logger logger = LoggerFactory.getLogger(WFSStoreProvider.class); |
102 |
public static String NAME = "WFSStore"; |
103 |
public static String DESCRIPTION = "WFS store to load WFS resources"; |
104 |
|
105 |
private static final MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
106 |
private static final String METADATA_DEFINITION_NAME = "WFSStore"; |
107 |
private static final String METADATA_DEFINITION_DESCRIPTION = "WFSStore metadata definition"; |
108 |
|
109 |
private IProjection projection;
|
110 |
private int featureCount = -1; |
111 |
private boolean isKnownEnvelope = false; |
112 |
|
113 |
/**
|
114 |
* GML provider used by delegation to read the GML files
|
115 |
*/
|
116 |
private GPEStoreProvider storeProviderDelegate = null; |
117 |
|
118 |
private static final DataManager dataManager = DALLocator.getDataManager(); |
119 |
private static final DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
120 |
private static final XMLSchemaManager xmlSchemaManager = XMLSchemaLocator.getXMLSchemaManager(); |
121 |
|
122 |
boolean isFilterByAreaSupported = true; |
123 |
|
124 |
//WFS Parameters
|
125 |
private WFSClient wfsClient;
|
126 |
private WFSStatus wfsStatus;
|
127 |
|
128 |
public WFSStoreProvider(DataStoreParameters params,
|
129 |
DataStoreProviderServices storeServices) |
130 |
throws InitializeException {
|
131 |
super(params, storeServices,
|
132 |
ToolsLocator.getDynObjectManager().createDynObject(metadataManager.getDefinition(METADATA_DEFINITION_NAME))); |
133 |
initParams(); |
134 |
try {
|
135 |
initFeatureType(); |
136 |
} catch (WFSException e) {
|
137 |
throw new InitializeException(e); |
138 |
} catch (ReadException e) {
|
139 |
throw new InitializeException(e); |
140 |
} |
141 |
} |
142 |
|
143 |
private void initParams() throws InitializeException{ |
144 |
try {
|
145 |
WFSStoreParameters wfsParameters = getWFSParameters(); |
146 |
try {
|
147 |
if (wfsParameters.getVersion() == null){ |
148 |
wfsClient = new WFSClient(wfsParameters.getUrl());
|
149 |
wfsParameters.setVersion(wfsClient.getVersion()); |
150 |
}else{
|
151 |
wfsClient = new WFSClient(wfsParameters.getUrl(), wfsParameters.getVersion());
|
152 |
} |
153 |
} catch (IOException e) { |
154 |
throw new InitializeException(e); |
155 |
} |
156 |
wfsStatus = new WFSStatus( wfsParameters.getFeatureType(),
|
157 |
wfsParameters.getFeatureNamespace()); |
158 |
wfsStatus.setNamespacePrefix(wfsParameters.getFeaturePrefix()); |
159 |
wfsStatus.setFields(wfsParameters.getFields()); |
160 |
//wfsStatus.setFilterQuery(wfsParameters.getFilterEncoding());
|
161 |
wfsStatus.setTimeout(wfsParameters.getTimeOut()); |
162 |
wfsStatus.setMaxFeatures(wfsParameters.getMaxFeatures()); |
163 |
wfsStatus.setUserName(wfsParameters.getUser()); |
164 |
wfsStatus.setPassword(wfsParameters.getPassword()); |
165 |
|
166 |
//Setting the envelope for the layer
|
167 |
wfsClient.getCapabilities(wfsStatus, false, null); |
168 |
|
169 |
Envelope envelope = calculateFullEnvelope(); |
170 |
if (envelope != null){ |
171 |
this.setDynValue("Envelope", envelope); |
172 |
isKnownEnvelope = true;
|
173 |
} |
174 |
} catch (WFSException e) {
|
175 |
throw new InitializeException("Impossible to retrieve the file", e); |
176 |
} |
177 |
} |
178 |
|
179 |
private WFSFeature getSelectedWFSFeature() throws ReadException, WFSException{ |
180 |
WFSStoreParameters wfsParameters = getWFSParameters(); |
181 |
|
182 |
return ((WFSServerExplorer)getExplorer()).getFeatureInfo(wfsParameters.getFeatureNamespace(),
|
183 |
wfsParameters.getFeatureType()); |
184 |
} |
185 |
|
186 |
private void initFeatureType() throws WFSException, ReadException{ |
187 |
WFSFeature feature = getSelectedWFSFeature(); |
188 |
|
189 |
if (feature == null){ |
190 |
//TODO read from GML
|
191 |
throw new WFSException("It is not possible to parse the schema"); |
192 |
} |
193 |
|
194 |
projection = CRSFactory.getCRS(getEPSGCode(feature.getDefaultSRS())); |
195 |
this.setDynValue("CRS", projection); |
196 |
|
197 |
EditableFeatureType featureType = getStoreServices().createFeatureType(); |
198 |
|
199 |
for (int i=0 ; i<feature.getFieldSize() ; i++){ |
200 |
WFSFeatureField featureField = feature.getFieldAt(i); |
201 |
int dataType = DataTypes.OBJECT;
|
202 |
String typeName = featureField.getType();
|
203 |
EditableFeatureAttributeDescriptor attributeDescriptor = null;
|
204 |
|
205 |
IXSTypeDefinition typeDefinition = xmlSchemaManager.getTypeDefinition(typeName); |
206 |
if (typeDefinition != null){ |
207 |
if (typeDefinition.getDataType() != null){ |
208 |
dataType = typeDefinition.getDataType().getType(); |
209 |
} |
210 |
attributeDescriptor = featureType.add(featureField.getName(), dataType); |
211 |
if (typeDefinition instanceof IXSGeometryTypeDefinition){ |
212 |
if (feature.getSrs().size() > 0){ |
213 |
attributeDescriptor.setSRS(CRSFactory.getCRS(getEPSGCode((String)feature.getSrs().get(0)))); |
214 |
} |
215 |
attributeDescriptor.setGeometryType(((IXSGeometryTypeDefinition)typeDefinition).getGeometryType()); |
216 |
attributeDescriptor.setGeometrySubType(SUBTYPES.GEOM2D); |
217 |
featureType.setDefaultGeometryAttributeName(featureField.getName()); |
218 |
} |
219 |
}else{
|
220 |
attributeDescriptor = featureType.add(typeName, dataType); |
221 |
} |
222 |
} |
223 |
featureType.add("gid", DataTypes.LONG);
|
224 |
featureType.setHasOID(true);
|
225 |
|
226 |
FeatureType defaultType = featureType.getNotEditableCopy(); |
227 |
List types = new ArrayList(1); |
228 |
types.add(defaultType); |
229 |
this.getStoreServices().setFeatureTypes(types, defaultType);
|
230 |
} |
231 |
|
232 |
private Envelope calculateFullEnvelope() {
|
233 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
234 |
|
235 |
try{
|
236 |
WFSFeature feature = getSelectedWFSFeature(); |
237 |
if (feature != null){ |
238 |
if (feature.getSrs().size() > 0){ |
239 |
String srs = feature.getDefaultSRS();
|
240 |
BoundaryBox boundaryBox = feature.getBbox(srs); |
241 |
if (boundaryBox == null) |
242 |
{ |
243 |
boundaryBox = feature.getBbox(getEPSGCode(srs)); |
244 |
} |
245 |
//The projection is found
|
246 |
if (boundaryBox != null){ |
247 |
return geometryManager.createEnvelope(boundaryBox.getXmin(),
|
248 |
boundaryBox.getYmin(), boundaryBox.getXmax(), boundaryBox.getYmax(), SUBTYPES.GEOM2D); |
249 |
} |
250 |
//Check if there is a latlon envelope
|
251 |
boundaryBox = feature.getLatLonBbox(); |
252 |
if (boundaryBox != null){ |
253 |
Envelope envelope = geometryManager.createEnvelope(boundaryBox.getXmin(), |
254 |
boundaryBox.getYmin(), boundaryBox.getXmax(), boundaryBox.getYmax(), SUBTYPES.GEOM2D); |
255 |
IProjection sourceProjection = CRSFactory.getCRS(getEPSGCode("EPSG:4326"));
|
256 |
IProjection destinationProjection = CRSFactory.getCRS(getEPSGCode(srs)); |
257 |
if (destinationProjection != null){ |
258 |
ICoordTrans coordTrans = sourceProjection.getCT(destinationProjection); |
259 |
return envelope.convert(coordTrans);
|
260 |
} |
261 |
} |
262 |
}else{
|
263 |
//If there is not a SRS is thrown a request for the first 500 features
|
264 |
int odlMaxFeatures = wfsStatus.getMaxFeatures();
|
265 |
wfsStatus.setMaxFeatures(500);
|
266 |
createSet(null, null); |
267 |
return storeProviderDelegate.getEnvelope();
|
268 |
} |
269 |
} |
270 |
}catch(CreateEnvelopeException e){
|
271 |
logger.error("Impossible to create an envelope", e);
|
272 |
} catch (ReadException e) {
|
273 |
logger.error("Impossible to create an envelope", e);
|
274 |
} catch (WFSException e) {
|
275 |
logger.error("Impossible to create an envelope", e);
|
276 |
} catch (DataException e) {
|
277 |
logger.error("Impossible to create an envelope", e);
|
278 |
} |
279 |
return null; |
280 |
} |
281 |
|
282 |
private WFSStoreParameters getWFSParameters() {
|
283 |
return (WFSStoreParameters) getParameters();
|
284 |
} |
285 |
|
286 |
/* (non-Javadoc)
|
287 |
* @see org.gvsig.fmap.dal.store.gpe.GPEStoreProvider#open()
|
288 |
*/
|
289 |
public void open() throws OpenException { |
290 |
try {
|
291 |
List featureTypes = this.getFeatureStore().getFeatureTypes(); |
292 |
for (int i=0 ; i<featureTypes.size() ; i++){ |
293 |
FeatureType featureType = (FeatureType)featureTypes.get(i); |
294 |
} |
295 |
} catch (DataException e) {
|
296 |
throw new OpenException("Reading the geometry type", e); |
297 |
} |
298 |
} |
299 |
|
300 |
protected static void registerMetadataDefinition() throws MetadataException { |
301 |
if (metadataManager.getDefinition(METADATA_DEFINITION_NAME) == null) { |
302 |
DynStruct metadataDefinition = metadataManager.addDefinition( |
303 |
METADATA_DEFINITION_NAME, METADATA_DEFINITION_DESCRIPTION); |
304 |
|
305 |
metadataDefinition.addDynFieldObject("Envelope").setClassOfValue(Envelope.class).setMandatory(false); |
306 |
metadataDefinition.addDynFieldObject("CRS").setClassOfValue(IProjection.class).setMandatory(true); |
307 |
|
308 |
metadataDefinition.extend(metadataManager |
309 |
.getDefinition(FeatureStore.METADATA_DEFINITION_NAME)); |
310 |
} |
311 |
} |
312 |
|
313 |
/* (non-Javadoc)
|
314 |
* @see org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider#getExplorer()
|
315 |
*/
|
316 |
public DataServerExplorer getExplorer() throws ReadException { |
317 |
DataManager manager = DALLocator.getDataManager(); |
318 |
WFSServerExplorerParameters params; |
319 |
try {
|
320 |
params = (WFSServerExplorerParameters) manager |
321 |
.createServerExplorerParameters(WFSServerExplorer.NAME); |
322 |
params.setUrl(wfsClient.getHost()); |
323 |
return manager.openServerExplorer(WFSServerExplorer.NAME,params);
|
324 |
} catch (Exception e) { |
325 |
throw new ReadException(this.getName(), e); |
326 |
} |
327 |
} |
328 |
|
329 |
|
330 |
/* (non-Javadoc)
|
331 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getName()
|
332 |
*/
|
333 |
public String getProviderName() { |
334 |
return NAME;
|
335 |
} |
336 |
|
337 |
public FeatureSetProvider createSet(FeatureQuery query)
|
338 |
throws DataException {
|
339 |
return createSet(query, null); |
340 |
} |
341 |
|
342 |
public FeatureSetProvider createSet(FeatureQuery query,
|
343 |
FeatureType featureType) throws DataException {
|
344 |
File file = null; |
345 |
if (query == null){ |
346 |
file = executeQuery(); |
347 |
}else{
|
348 |
//If it is possible to execute a spatial query...
|
349 |
if (query.getFilter() != null){ |
350 |
file = executeSpatialQuery(query); |
351 |
}else{
|
352 |
file = executeQuery(); |
353 |
} |
354 |
|
355 |
} |
356 |
|
357 |
storeProviderDelegate = createProvider(file); |
358 |
return storeProviderDelegate.createSet(query, featureType);
|
359 |
} |
360 |
|
361 |
|
362 |
|
363 |
/**
|
364 |
* It creates the provider that is used to retrieve features from a file.
|
365 |
* @param file
|
366 |
* the file that contains the downloaded file
|
367 |
* @return
|
368 |
* @throws InitializeException
|
369 |
* @throws ProviderNotRegisteredException
|
370 |
*/
|
371 |
private GPEStoreProvider createProvider(File file) throws InitializeException, ProviderNotRegisteredException{ |
372 |
return new GPEStoreProvider(createStoreParameters(file), getStoreServices()); |
373 |
} |
374 |
|
375 |
private DataStoreParameters createStoreParameters(File file) throws InitializeException, ProviderNotRegisteredException{ |
376 |
DataStoreParameters parameters = dataManager.createStoreParameters(GPEStoreProvider.NAME); |
377 |
|
378 |
parameters.setDynValue("File", file.getAbsolutePath());
|
379 |
parameters.setDynValue("Envelope", this.getDynValue("Envelope")); |
380 |
return parameters;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* It executes a wfs Query without spatial filter
|
385 |
* @throws DataException
|
386 |
*/
|
387 |
private File executeQuery() throws DataException{ |
388 |
try{
|
389 |
wfsStatus.setResultType(WFSStatus.RESULTYPE_RESULTS); |
390 |
return wfsClient.getFeature(wfsStatus, true, null); |
391 |
} catch (WFSException e) {
|
392 |
throw new InitializeException("Impossible to retrieve the file", e); |
393 |
} |
394 |
} |
395 |
|
396 |
/**
|
397 |
* Executes a new query sending the FilterEncoding request to the server
|
398 |
* @param query
|
399 |
* The Query to send
|
400 |
* @throws InitializeException
|
401 |
* If there is a problem with the request or the parsing process
|
402 |
*/
|
403 |
private File executeSpatialQuery(FeatureQuery query) throws DataException{ |
404 |
EvaluatorFieldsInfo fieldsInfo = query.getFilter().getFieldsInfo(); |
405 |
String[] fields = fieldsInfo.getFieldNames(); |
406 |
for (int i=0 ; i<fields.length ; i++){ |
407 |
EvaluatorFieldValue[] evaluatorFieldValues = fieldsInfo.getFieldValues(fields[i]);
|
408 |
for (int j=0 ; j<evaluatorFieldValues.length ; j++){ |
409 |
if (EvaluatorFieldValue.MATCH == evaluatorFieldValues[j].getType()){
|
410 |
EvaluatorFieldValueMatch evaluatorFieldValueMatch = (EvaluatorFieldValueMatch)evaluatorFieldValues[j]; |
411 |
Object area = evaluatorFieldValueMatch.getValue();
|
412 |
if (area instanceof Envelope){ |
413 |
return executeSpatialQueryFromEnvelope(evaluatorFieldValueMatch.getFieldName(),
|
414 |
(Envelope)area); |
415 |
}else if (area instanceof Geometry){ |
416 |
return executeSpatialQueryFromGeometry(evaluatorFieldValueMatch.getFieldName(),
|
417 |
(Geometry)area); |
418 |
} |
419 |
} |
420 |
} |
421 |
} |
422 |
return null; |
423 |
} |
424 |
|
425 |
private File executeSpatialQueryFromGeometry(String the_geom, Geometry geometry) throws DataException{ |
426 |
wfsStatus.setFilterByArea(geometry, the_geom, projection.getAbrev(), |
427 |
FilterEncoding.GEOMETRIC_OPERATOR_CONTAINS); |
428 |
return executeSpatialQuery();
|
429 |
} |
430 |
|
431 |
private File executeSpatialQueryFromEnvelope(String the_geom, Envelope envelope) throws DataException{ |
432 |
wfsStatus.setFilterByArea(envelope, the_geom, projection.getAbrev(), |
433 |
FilterEncoding.GEOMETRIC_OPERATOR_CONTAINS); |
434 |
return executeSpatialQuery();
|
435 |
} |
436 |
|
437 |
private File executeSpatialQuery() throws DataException{ |
438 |
try {
|
439 |
wfsStatus.setProtocol(OGCClientOperation.PROTOCOL_POST); |
440 |
//If it is not possible to calculate the
|
441 |
wfsStatus.setResultType(WFSStatus.RESULTYPE_RESULTS); |
442 |
return wfsClient.getFeature(wfsStatus, true, null); |
443 |
} catch (WFSException e) {
|
444 |
throw new InitializeException("Impossible to retrieve the file", e); |
445 |
} |
446 |
} |
447 |
|
448 |
public Object getSourceId() { |
449 |
StringBuffer sourceID = new StringBuffer(getWFSParameters().getUrl()); |
450 |
sourceID.append("_" + getWFSParameters().getFeatureType());
|
451 |
int hash = sourceID.hashCode();
|
452 |
if (sourceID.length() > 60){ |
453 |
return sourceID.substring(0, 60) + "_" + hash; |
454 |
}else{
|
455 |
return sourceID.toString() + "_" + hash; |
456 |
} |
457 |
} |
458 |
|
459 |
private String getEPSGCode(String srs){ |
460 |
if (srs == null){ |
461 |
return null; |
462 |
} |
463 |
if (srs.startsWith("urn:x-ogc:def:crs:")){ |
464 |
String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length()); |
465 |
if (srs.indexOf("EPSG") > 0){ |
466 |
if (newString.indexOf("EPSG") < 0){ |
467 |
newString = "EPSG:" + newString;
|
468 |
} |
469 |
} |
470 |
return newString;
|
471 |
} |
472 |
if (srs.toLowerCase().startsWith("crs:")){ |
473 |
return srs.substring(4, srs.length()); |
474 |
} |
475 |
return srs;
|
476 |
} |
477 |
|
478 |
public Object createNewOID() { |
479 |
// TODO Auto-generated method stub
|
480 |
return null; |
481 |
} |
482 |
|
483 |
public long getFeatureCount() throws DataException { |
484 |
if (featureCount == -1){ |
485 |
wfsStatus.setResultType(WFSStatus.RESULTYPE_HITS); |
486 |
try {
|
487 |
wfsClient.getFeature(wfsStatus, true, null); |
488 |
featureCount = ((WFSGetFeatureRequestInformation)wfsClient.getLastWfsRequestInformation()).getNumberOfFeatures(); |
489 |
} catch (WFSException e) {
|
490 |
throw new ConnectionServerException("Error calculating the feature count", e); |
491 |
} |
492 |
} |
493 |
return featureCount;
|
494 |
} |
495 |
|
496 |
public int getOIDType() { |
497 |
// TODO Auto-generated method stub
|
498 |
return 0; |
499 |
} |
500 |
|
501 |
public ResourceProvider getResource() {
|
502 |
return storeProviderDelegate.getResource();
|
503 |
} |
504 |
|
505 |
protected FeatureProvider internalGetFeatureProviderByReference(
|
506 |
FeatureReferenceProviderServices reference, FeatureType featureType) |
507 |
throws DataException {
|
508 |
return storeProviderDelegate.internalGetFeatureProviderByReference(reference, featureType);
|
509 |
} |
510 |
|
511 |
public String getFullName() { |
512 |
return getWFSParameters().getUrl() + "_" + getWFSParameters().getFeatureType(); |
513 |
} |
514 |
|
515 |
public String getName() { |
516 |
return getFullName();
|
517 |
} |
518 |
|
519 |
public boolean isKnownEnvelope(){ |
520 |
return isKnownEnvelope;
|
521 |
} |
522 |
|
523 |
public boolean hasRetrievedFeaturesLimit(){ |
524 |
return true; |
525 |
} |
526 |
|
527 |
public int getRetrievedFeaturesLimit(){ |
528 |
//WFS 1.0.0 can not know where is the limit
|
529 |
if (getWFSParameters().getVersion().equals("1.0.0")){ |
530 |
return 0; |
531 |
}else{
|
532 |
return wfsClient.getServiceInformation().getMaxFeatures();
|
533 |
} |
534 |
} |
535 |
|
536 |
public void performChanges(Iterator deleteds, Iterator inserteds, |
537 |
Iterator updateds, Iterator featureTypesChanged) |
538 |
throws DataException {
|
539 |
// FIXME exception
|
540 |
throw new UnsupportedOperationException(); |
541 |
} |
542 |
|
543 |
public boolean allowWrite() { |
544 |
return wfsClient.getServiceInformation().isOperationSupported("Transaction"); |
545 |
} |
546 |
|
547 |
public Envelope getEnvelope() throws DataException { |
548 |
return (Envelope) this.getDynValue("Envelope"); |
549 |
} |
550 |
} |
551 |
|