Search in sources :

Example 6 with RTreeBuilder

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

the class TestRTreeIndex method testBoxQuery5d.

/**
 * Test to query the index
 */
@Test(timeout = 60000)
public void testBoxQuery5d() {
    final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(5);
    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 7 with RTreeBuilder

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

the class TestRTreeMemoryDeserializer method testSerializeIndexSmall.

/**
 * Test the encoding and the decoding of the index with only one entry
 * = data is encoded in the root node
 *
 * @throws StorageManagerException
 * @throws IOException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testSerializeIndexSmall() throws StorageManagerException, IOException, InterruptedException {
    final List<SpatialIndexEntry> tupleList = new ArrayList<>();
    tupleList.add(new SpatialIndexEntry(new BoundingBox(1.0, 1.2), 2));
    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();
    final List<? extends SpatialIndexEntry> resultList = indexRead.getEntriesForRegion(new BoundingBox(1.1, 1.2));
    Assert.assertEquals(1, resultList.size());
    indexRead.close();
}
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) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 8 with RTreeBuilder

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

the class TestRTreeIndex method testBoxQuery4d.

/**
 * Test to query the index
 */
@Test(timeout = 60000)
public void testBoxQuery4d() {
    final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(4);
    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 9 with RTreeBuilder

use of org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder 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 10 with RTreeBuilder

use of org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder 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)

Aggregations

RTreeBuilder (org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder)15 Test (org.junit.Test)15 SpatialIndexBuilder (org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder)12 SpatialIndexEntry (org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)12 File (java.io.File)4 RandomAccessFile (java.io.RandomAccessFile)4 AbstractRTreeReader (org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader)4 BoundingBox (org.bboxdb.commons.math.BoundingBox)2 ArrayList (java.util.ArrayList)1