Search in sources :

Example 16 with SpatialIndexEntry

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);
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) Test(org.junit.Test)

Example 17 with SpatialIndexEntry

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());
}
Also used : Path(java.nio.file.Path) RandomAccessFile(java.io.RandomAccessFile) BoundingBox(org.bboxdb.commons.math.BoundingBox) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 18 with SpatialIndexEntry

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());
}
Also used : RandomAccessFile(java.io.RandomAccessFile) BoundingBox(org.bboxdb.commons.math.BoundingBox) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 19 with SpatialIndexEntry

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);
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) Test(org.junit.Test)

Example 20 with SpatialIndexEntry

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);
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) Test(org.junit.Test)

Aggregations

SpatialIndexEntry (org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)27 Test (org.junit.Test)14 SpatialIndexBuilder (org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder)13 RTreeBuilder (org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder)12 BoundingBox (org.bboxdb.commons.math.BoundingBox)8 RandomAccessFile (java.io.RandomAccessFile)6 ArrayList (java.util.ArrayList)6 StorageManagerException (org.bboxdb.storage.StorageManagerException)6 File (java.io.File)5 AbstractRTreeReader (org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader)4 List (java.util.List)3 Random (java.util.Random)3 Collectors (java.util.stream.Collectors)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 SpatialIndexReader (org.bboxdb.storage.sstable.spatialindex.SpatialIndexReader)2 Assert (org.junit.Assert)2 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1