IndexexShapefileDataStore produces inaccurate results with fid filters
----------------------------------------------------------------------
Key: GEOT-2050
URL: http://jira.codehaus.org/browse/GEOT-2050
Project: GeoTools
Issue Type: Bug
Components: data shapefile
Affects Versions: 2.5.0
Reporter: Gabriel Roldán
Assignee: Gabriel Roldán
Fix For: 2.5.1
IndexedShapefileDataStore does not handle fid filters correctly.
Added the below test case which exposes the defect and produces the following
failure:
AssertionFailedError: lacking fids: [statepop.20, statepop.30, statepop.31,
statepop.32, statepop.40, statepop.41, statepop.42, statepop.43]. Unexpected
ones: [] expected:<49> but was:<41>
{code}
public void testFidFilter() throws Exception {
URL url;
{
File shpFile = copyShapefiles(STATE_POP);
url = shpFile.toURL();
String filename = url.getFile();
filename = filename.substring(0, filename.lastIndexOf("."));
// force creating the index
File file = new File(filename + ".qix");
if (file.exists()) {
file.delete();
}
file.deleteOnExit();
}
IndexedShapefileDataStore ds = new IndexedShapefileDataStore(url, null,
true, true,
IndexType.QIX);
FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
ds.getFeatureSource();
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
featureSource.getFeatures();
FeatureIterator<SimpleFeature> indexIter = features.features();
Set<String> expectedFids = new HashSet<String>();
final Filter fidFilter;
try {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
Set<FeatureId> fids = new HashSet<FeatureId>();
while (indexIter.hasNext()) {
SimpleFeature newFeature = indexIter.next();
String id = newFeature.getID();
expectedFids.add(id);
fids.add(ff.featureId(id));
}
fidFilter = ff.id(fids);
} finally {
indexIter.close();
}
Set<String> actualFids = new HashSet<String>();
{
features = featureSource.getFeatures(fidFilter);
indexIter = features.features();
while (indexIter.hasNext()) {
SimpleFeature next = indexIter.next();
String id = next.getID();
actualFids.add(id);
}
}
TreeSet<String> lackingFids = new TreeSet<String>(expectedFids);
lackingFids.removeAll(actualFids);
TreeSet<String> unexpectedFids = new TreeSet<String>(actualFids);
unexpectedFids.removeAll(expectedFids);
String lacking = String.valueOf(lackingFids);
String unexpected = String.valueOf(unexpectedFids);
String failureMsg = "lacking fids: " + lacking + ". Unexpected ones: "
+ unexpected;
assertEquals(failureMsg, expectedFids.size(), actualFids.size());
assertEquals(failureMsg, expectedFids, actualFids);
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel