use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class TestRTreeIndex method testBoxQuery3d.
/**
* Test to query the index
*/
@Test(timeout = 60000)
public void testBoxQuery3d() {
final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(3);
final SpatialIndexBuilder index = new RTreeBuilder();
index.bulkInsert(tupleList);
RTreeTestHelper.queryIndex(tupleList, index);
}
use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class TestRTreeIndex method testEncodeDecodeRTreeEntryFromByteBuffer.
/**
* Test the decoding an encoding of an rtree entry
* @throws IOException
*/
@Test(timeout = 60000)
public void testEncodeDecodeRTreeEntryFromByteBuffer() throws IOException {
final BoundingBox boundingBox = new BoundingBox(4.1, 8.1, 4.2, 8.8);
final File tempFile = File.createTempFile("rtree-", "-test");
tempFile.deleteOnExit();
final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
final SpatialIndexEntry rTreeSpatialIndexEntry = new SpatialIndexEntry(boundingBox, 1);
rTreeSpatialIndexEntry.writeToFile(raf);
raf.close();
final Path path = Paths.get(tempFile.getAbsolutePath());
final byte[] data = Files.readAllBytes(path);
final ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(Const.APPLICATION_BYTE_ORDER);
final SpatialIndexEntry readEntry = SpatialIndexEntry.readFromByteBuffer(bb);
Assert.assertEquals(rTreeSpatialIndexEntry.getValue(), readEntry.getValue());
Assert.assertEquals(rTreeSpatialIndexEntry.getBoundingBox(), readEntry.getBoundingBox());
}
use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class TestRTreeIndex method testEncodeDecodeRTreeEntryFromFile.
/**
* Test the decoding an encoding of an rtree entry
* @throws IOException
*/
@Test(timeout = 60000)
public void testEncodeDecodeRTreeEntryFromFile() throws IOException {
final BoundingBox boundingBox = new BoundingBox(4.1, 8.1, 4.2, 8.8);
final File tempFile = File.createTempFile("rtree-", "-test");
tempFile.deleteOnExit();
final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
final SpatialIndexEntry rTreeSpatialIndexEntry = new SpatialIndexEntry(boundingBox, 1);
rTreeSpatialIndexEntry.writeToFile(raf);
raf.close();
final RandomAccessFile rafRead = new RandomAccessFile(tempFile, "r");
final SpatialIndexEntry readEntry = SpatialIndexEntry.readFromFile(rafRead);
rafRead.close();
Assert.assertEquals(rTreeSpatialIndexEntry.getValue(), readEntry.getValue());
Assert.assertEquals(rTreeSpatialIndexEntry.getBoundingBox(), readEntry.getBoundingBox());
}
use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class TestRTreeIndex method testBoxQuery2d.
/**
* Test to query the index
*/
@Test(timeout = 60000)
public void testBoxQuery2d() {
final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(2);
final SpatialIndexBuilder index = new RTreeBuilder();
index.bulkInsert(tupleList);
RTreeTestHelper.queryIndex(tupleList, index);
}
use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class TestRTreeIndex method testBoxQuery1d.
/**
* Test to query the index
*/
@Test(timeout = 60000)
public void testBoxQuery1d() {
final List<SpatialIndexEntry> tupleList = RTreeTestHelper.getEntryList();
final SpatialIndexBuilder index = new RTreeBuilder();
index.bulkInsert(tupleList);
RTreeTestHelper.queryIndex(tupleList, index);
}
Aggregations