Search in sources :

Example 1 with SpatialIndexEntry

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

the class RTreeTestHelper method queryIndex.

/**
 * Test the query
 *
 * @param entries
 * @param index
 * @throws StorageManagerException
 */
public static void queryIndex(final List<SpatialIndexEntry> entries, final SpatialIndexReader index) throws StorageManagerException {
    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 2 with SpatialIndexEntry

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

the class RTreeTestHelper method getEntryList.

/**
 * Generate a list of tuples
 * @return
 */
public static List<SpatialIndexEntry> getEntryList() {
    final List<SpatialIndexEntry> entryList = new ArrayList<SpatialIndexEntry>();
    entryList.add(new SpatialIndexEntry(new BoundingBox(0d, 1d, 0d, 1d), 1));
    entryList.add(new SpatialIndexEntry(new BoundingBox(1d, 2d, 1d, 3d), 2));
    entryList.add(new SpatialIndexEntry(new BoundingBox(2d, 3d, 0d, 1d), 3));
    entryList.add(new SpatialIndexEntry(new BoundingBox(3d, 4d, 3d, 7d), 4));
    entryList.add(new SpatialIndexEntry(new BoundingBox(1.2d, 2.2d, 0d, 1d), 5));
    entryList.add(new SpatialIndexEntry(new BoundingBox(4.6d, 5.6d, 0d, 1d), 6));
    entryList.add(new SpatialIndexEntry(new BoundingBox(5.2d, 6.2d, 4d, 5d), 7));
    entryList.add(new SpatialIndexEntry(new BoundingBox(5.1d, 6.1d, 0d, 1d), 8));
    entryList.add(new SpatialIndexEntry(new BoundingBox(6.1d, 7.1d, 0d, 1d), 9));
    entryList.add(new SpatialIndexEntry(new BoundingBox(8.1d, 9.1d, 2d, 5d), 10));
    return entryList;
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Example 3 with SpatialIndexEntry

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

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

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

the class TestRTreeIndex method testCovering.

/**
 * Test the covering of the nodes
 */
@Test(timeout = 60000)
public void testCovering() {
    final List<SpatialIndexEntry> tupleList = RTreeTestHelper.generateRandomTupleList(3);
    final RTreeBuilder index = new RTreeBuilder();
    index.bulkInsert(tupleList);
    index.testCovering();
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) 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