Author: aaime
Date: 2009-10-26 21:08:51 -0400 (Mon, 26 Oct 2009)
New Revision: 34255
Modified:
trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java
trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStoreTest.java
Log:
GEOT-2799 Shapefile Query for FeatureIds fails
Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java
===================================================================
--- trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java 2009-10-26 12:54:24 UTC (rev 34254)
+++ trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java 2009-10-27 01:08:51 UTC (rev 34255)
@@ -288,7 +288,8 @@
String defaultGeomName = schema.getGeometryDescriptor().getLocalName();
- if(propertyNames.length > 0) {
+ // add the attributes we need to read to keep the filtering going
+ if(propertyNames.length > 0) {
FilterAttributeExtractor fae = new FilterAttributeExtractor();
query.getFilter().accept(fae, null);
@@ -299,26 +300,25 @@
.size()]);
}
+ // check what we actually have to read
SimpleFeatureType newSchema = schema;
boolean readDbf = true;
boolean readGeometry = true;
try {
- if (((query.getPropertyNames() != null)
+ if (((query.getPropertyNames() != Query.NO_NAMES)
&& (propertyNames.length == 1) && propertyNames[0]
.equals(defaultGeomName))) {
readDbf = false;
newSchema = createSubType( propertyNames);
- } else if ((query.getPropertyNames() != null)
+ } else if ((query.getPropertyNames() == Query.NO_NAMES)
&& (propertyNames.length == 0)) {
readDbf = false;
readGeometry = false;
newSchema = createSubType( propertyNames);
- }
- else if( propertyNames.length > 0 && !propertyNames[0].equals(defaultGeomName) ){
+ } else if( propertyNames.length > 0 && !propertyNames[0].equals(defaultGeomName) ){
readGeometry = false;
newSchema = createSubType(propertyNames);
- }
- else if(propertyNames.length > 0) {
+ } else if(propertyNames.length > 0) {
newSchema = createSubType(propertyNames);
}
Modified: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStoreTest.java
===================================================================
--- trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStoreTest.java 2009-10-26 12:54:24 UTC (rev 34254)
+++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStoreTest.java 2009-10-27 01:08:51 UTC (rev 34255)
@@ -323,10 +323,6 @@
ds2.dispose();
}
- /**
- * A FeatureCollection that only has FeatureIds (ie no geometry no attributes)
- * is used to model "selection" in uDig.
- */
public void testSelectionQuery() throws Exception {
File shpFile = copyShapefiles(STATE_POP);
URL url = shpFile.toURI().toURL();
@@ -340,14 +336,27 @@
assertNotNull( "selection query worked", features );
assertTrue( "selection non empty", features.size() > 0 );
+ ReferencedEnvelope bounds = features.getBounds();
+
final Set<FeatureId> selection = new LinkedHashSet<FeatureId>();
- features.accepts( new FeatureVisitor() {
+ features.accepts( new FeatureVisitor() {
public void visit(Feature feature) {
selection.add( feature.getIdentifier() );
}
}, null );
+ assertFalse( selection.isEmpty() );
+ // try with filter and no attributes
+ FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
+ String geomName = schema.getGeometryDescriptor().getName().getLocalPart();
+
+ query.setFilter( ff.bbox( ff.property(geomName), bounds) );
+ features = featureSource.getFeatures( query );
+
+ assertNotNull( "selection query worked", features );
+ assertTrue( "selection non empty", features.size() > 0 );
}
+
public void testFidFilter() throws Exception {
File shpFile = copyShapefiles(STATE_POP);
URL url = shpFile.toURI().toURL();
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits