use of org.geotoolkit.index.CloseableCollection in project geotoolkit by Geomatys.
the class FileSystemNodeTest method testNoerror.
/**
* Just test it doesn't raise an error.
* TODO : move tests from shapefile.
*/
@Test
public void testNoerror() throws Exception {
final File file = new File("src/test/resources/org/geotoolkit/index/sample.qix");
final FileSystemIndexStore store = new FileSystemIndexStore(file);
final DataReader reader = new DataReader() {
@Override
public Data read(final int id) throws IOException {
return new DefaultData(DATA_DEFINITION) {
@Override
public String toString() {
return Integer.toString(id);
}
};
}
@Override
public void close() throws IOException {
}
@Override
public void read(int[] ids, Data[] buffer, int size) throws IOException {
for (int i = 0; i < size; i++) {
buffer[i] = read(ids[i]);
}
}
};
final QuadTree tree = store.load();
assertEquals(10, tree.getMaxDepth());
assertEquals(new Envelope(-8.86966023318779, 3.188061808903407, 36.113981340792286, 43.55971524165336), tree.getRoot().getBounds(new Envelope()));
assertEquals(3602, tree.getNumShapes());
final AbstractNode root = tree.getRoot();
for (int i = 0; i < 4; i++) {
root.getSubNode(i);
}
CloseableCollection col = tree.search(reader, new Envelope(-8, 3, 37, 40));
Iterator ite = col.iterator();
while (ite.hasNext()) {
ite.next();
}
}
Aggregations