Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 2.4-RC0, 2.5-M0
-
Fix Version/s: 2.7.6
-
Component/s: wfs plugin
-
Labels:None
-
Environment:Fedora 7 (kernel 2.6.22.5-76.fc7)
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)
Description
The getFeatures(Query query) method from WFSFeatureSource doesn't work with the Query.ALL filter. This is because Query.ALL doesn't specify a typeName, and this triggers the execution of the if (query.getTypeName() == null) branch. This creates an ad-hoc ALL inclusive query for the source type name, but it doesn't actually use it.
Proposed fix is attached.
This is my code:
String getCapabilities = "http://myserver:8080/ws/dasoghe?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities";
Map<Object, Object> connectionParameters = new HashMap<Object, Object>();
connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
getCapabilities);
DataStore data = DataStoreFinder.getDataStore(connectionParameters);
String typeNames[] = data.getTypeNames();
String typeName = typeNames[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = data.getFeatureSource(typeName);
FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures();
assertEquals(3, features.size());
I know in the first feature type there are 3 features, but the last assertion fails: the FeatureCollection is empty (size == 0). I double checked that the feature type queried is the right one (I removed some debug logging from the code above).
I have to use this code in order to read the features:
String geomName = schema.getGeometryDescriptor().getLocalName();
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2( GeoTools.getDefaultHints() );
Object polygon = JTS.toGeometry( (com.vividsolutions.jts.geom.Envelope)source.getBounds() );
Intersects filter = ff.intersects( ff.property( geomName ), ff.literal( polygon ) );
Query query = new DefaultQuery( typeName, filter, new String[]{ geomName } );
features = source.getFeatures( query );
That is, a spatial filter with a bbox equals to the bounds envelope. Very very bad: I have to do a spatial query in order to read my feature?
I just updated from geotools 2.4 and that test (source.getFeatures()) was working fine. It seems to me a very bad regression.
Regards,
Fabio