Search in sources :

Example 1 with SpatialIndexReader

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

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 BoundingBox (org.bboxdb.commons.math.BoundingBox)1 StorageManagerException (org.bboxdb.storage.StorageManagerException)1 SpatialIndexBuilder (org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder)1 SpatialIndexEntry (org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)1 SpatialIndexReader (org.bboxdb.storage.sstable.spatialindex.SpatialIndexReader)1 Assert (org.junit.Assert)1