Hi everyone,
Im trying to read some VMAP-Data with the VPFLibrary and encountered a
strange behaviour in the DefaultFeatureResults -Class.
After reading data from the Library like this:
VPFLibrary lib = new VPFLibrary(library);
String[] types = lib.getTypeNames();
for (int i = 0; i < types.length; i++)
{
String featureTypeName = types[i];
System.out.println("###################");
System.out.println("TypeName: " + featureTypeName);
FeatureSource featureSource = lib.getFeatureSource(featureTypeName);
FeatureType type = featureSource.getSchema();
FeatureCollection coll = featureSource.getFeatures();
System.out.println("FeatureSize: " + coll.size());
Iterator<Feature> it = coll.iterator();
System.out.println("Features:");
while(it.hasNext()) {
Feature f = it.next();
System.out.println(f.toString());
}
}
the DefaultFeatureResults(a DefaultFeatureCollection) closed the
FeatureReader in its getCount()-Routine:
int count;
count = featureSource.getCount(query);
if (count != -1) {
// we have an optimization!
return count;
}
// Okay lets count the FeatureReader
try {
count = 0;
FeatureReader reader = reader();
for (; reader.hasNext(); count++) {
reader.next();
}
reader.close(); //Why does it close the Reader?
return count;
} catch (IllegalAttributeException e) {
throw new DataSourceException("Could not read feature ", e);
}
the FeatureReader then closed all Filehandles in its reset()-Routine (which
is called by close()):
VPFFile file = (VPFFile) featureType.getFeatureClass().getFileList().get(0);
file.reset();
VPFFileFactory.getInstance().reset(); //This closes all Handles
the Handles were not opened again and thus the following error occurred:
java.io.IOException: Das Handle ist ungültig
at java.io.RandomAccessFile.length(Native Method)
at org.geotools.data.vpf.file.VPFFile.hasNext(VPFFile.java:472)
at
org.geotools.data.vpf.VPFFeatureReader.readNext(VPFFeatureReader.java:142)
at
org.geotools.data.vpf.VPFFeatureReader.hasNext(VPFFeatureReader.java:114)
at
org.geotools.data.ReTypeFeatureReader.hasNext(ReTypeFeatureReader.java:164)
at
org.geotools.data.store.FeatureReaderIterator.hasNext(FeatureReaderIterator.
java:44)
Can anybody tell me why the reader is closed in the getCount()-Routine of
the DefaultFeatureResults-Class?
And why does the FeatureReader close all Handles in the reset()-Routine?
Greets,
Sebastian
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users