Search in sources :

Example 6 with SpatialIndexBuilder

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

the class RTreeTestHelper method queryIndex.

/**
 * Test the query
 *
 * @param entries
 * @param index
 */
public static void queryIndex(final List<SpatialIndexEntry> entries, final SpatialIndexBuilder index) {
    for (final SpatialIndexEntry entry : entries) {
        final List<? extends SpatialIndexEntry> resultList = index.getEntriesForRegion(entry.getBoundingBox());
        Assert.assertTrue(resultList.size() >= 1);
        final List<Integer> keyResult = resultList.stream().map(e -> e.getValue()).filter(k -> k.equals(entry.getValue())).collect(Collectors.toList());
        Assert.assertTrue("Searching for: " + entry, keyResult.size() == 1);
    }
}
Also used : List(java.util.List) SpatialIndexReader(org.bboxdb.storage.sstable.spatialindex.SpatialIndexReader) Random(java.util.Random) StorageManagerException(org.bboxdb.storage.StorageManagerException) Assert(org.junit.Assert) Collectors(java.util.stream.Collectors) BoundingBox(org.bboxdb.commons.math.BoundingBox) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) ArrayList(java.util.ArrayList) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Example 7 with SpatialIndexBuilder

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

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

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

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

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