Search in sources :

Example 1 with SpatialIndexBuilder

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

the class TestRTreeIndex method testBoxesInsert.

/**
 * Test to insert and to read the bounding boxes
 */
@Test(timeout = 60000)
public void testBoxesInsert() {
    final List<SpatialIndexEntry> elements = RTreeTestHelper.getEntryList();
    final SpatialIndexBuilder index = new RTreeBuilder();
    index.bulkInsert(elements);
}
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 2 with SpatialIndexBuilder

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

the class TestRTreeIndex method testBoxQuery10d.

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

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

the class TestRTreeIndex method testBoxQuery1d0.

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

use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder 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 5 with SpatialIndexBuilder

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

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