Search in sources :

Example 11 with SpatialIndexBuilder

use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder in project bboxdb by jnidzwetzki.

the class TestRTreeIndex method testQueryOnEmptytree.

@Test(timeout = 60000)
public void testQueryOnEmptytree() {
    final SpatialIndexBuilder index = new RTreeBuilder();
    final List<? extends SpatialIndexEntry> result = index.getEntriesForRegion(new BoundingBox(1d, 1d, 2d, 2d));
    Assert.assertTrue(result.isEmpty());
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 12 with SpatialIndexBuilder

use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder in project bboxdb by jnidzwetzki.

the class TestRTreeMemoryDeserializer method testSerializeIndex3D.

/**
 * Test the encoding and the decoding of the index
 * @throws StorageManagerException
 * @throws IOException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testSerializeIndex3D() throws StorageManagerException, IOException, InterruptedException {
    final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(3);
    final SpatialIndexBuilder index = new RTreeBuilder();
    index.bulkInsert(tupleList);
    RTreeTestHelper.queryIndex(tupleList, index);
    final File tempFile = File.createTempFile("rtree-", "-test");
    tempFile.deleteOnExit();
    final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
    index.writeToFile(raf);
    raf.close();
    final AbstractRTreeReader indexRead = getRTreeReader();
    final RandomAccessFile rafRead = new RandomAccessFile(tempFile, "r");
    indexRead.readFromFile(rafRead);
    rafRead.close();
    RTreeTestHelper.queryIndex(tupleList, indexRead);
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) RandomAccessFile(java.io.RandomAccessFile) AbstractRTreeReader(org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 13 with SpatialIndexBuilder

use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder in project bboxdb by jnidzwetzki.

the class TestRTreeMemoryDeserializer method testSerializeIndex1D.

/**
 * Test the encoding and the decoding of the index
 * @throws StorageManagerException
 * @throws IOException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testSerializeIndex1D() throws StorageManagerException, IOException, InterruptedException {
    final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(1);
    final SpatialIndexBuilder index = new RTreeBuilder();
    index.bulkInsert(tupleList);
    RTreeTestHelper.queryIndex(tupleList, index);
    final File tempFile = File.createTempFile("rtree-", "-test");
    tempFile.deleteOnExit();
    final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
    index.writeToFile(raf);
    raf.close();
    final AbstractRTreeReader indexRead = getRTreeReader();
    final RandomAccessFile rafRead = new RandomAccessFile(tempFile, "r");
    indexRead.readFromFile(rafRead);
    rafRead.close();
    RTreeTestHelper.queryIndex(tupleList, indexRead);
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) RandomAccessFile(java.io.RandomAccessFile) AbstractRTreeReader(org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Aggregations

SpatialIndexBuilder (org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder)13 SpatialIndexEntry (org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)12 RTreeBuilder (org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder)12 Test (org.junit.Test)12 File (java.io.File)3 RandomAccessFile (java.io.RandomAccessFile)3 BoundingBox (org.bboxdb.commons.math.BoundingBox)3 AbstractRTreeReader (org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 StorageManagerException (org.bboxdb.storage.StorageManagerException)1 SpatialIndexReader (org.bboxdb.storage.sstable.spatialindex.SpatialIndexReader)1 Assert (org.junit.Assert)1