Search in sources :

Example 1 with OverlapsBoundingBoxPredicate

use of org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate in project bboxdb by jnidzwetzki.

the class TestPredicates method boundingAndPredicate.

/**
 * Test the and predicate
 * @throws Exception
 */
@Test(timeout = 60000)
public void boundingAndPredicate() {
    final Tuple tuple1 = new Tuple("1", new BoundingBox(1.0, 10.0, 1.0, 10.9), "abc".getBytes(), 50);
    final Tuple tuple2 = new Tuple("2", new BoundingBox(-11.0, 0.0, -11.0, 0.9), "def".getBytes(), 1234);
    final List<Tuple> tupleList = new ArrayList<>();
    tupleList.add(tuple1);
    tupleList.add(tuple2);
    final Predicate predicate1 = new OverlapsBoundingBoxPredicate(new BoundingBox(2.0, 100.0, 2.0, 100.0));
    final Predicate predicate2 = new NewerAsVersionTimePredicate(51);
    final Predicate predicate = new AndPredicate(predicate1, predicate2);
    final Collection<Tuple> tuples = getTuplesFromPredicate(tupleList, predicate);
    Assert.assertTrue(tuples.isEmpty());
}
Also used : NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Tuple(org.bboxdb.storage.entity.Tuple) Predicate(org.bboxdb.storage.queryprocessor.predicate.Predicate) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Test(org.junit.Test)

Example 2 with OverlapsBoundingBoxPredicate

use of org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate in project bboxdb by jnidzwetzki.

the class TestPredicates method boundingBoxPredicate.

/**
 * Test the bounding box predicate
 * @throws Exception
 */
@Test(timeout = 60000)
public void boundingBoxPredicate() {
    final Tuple tuple1 = new Tuple("1", new BoundingBox(1.0, 10.0, 1.0, 10.9), "abc".getBytes(), 50);
    final Tuple tuple2 = new Tuple("2", new BoundingBox(-11.0, 0.0, -11.0, 0.9), "def".getBytes(), 1234);
    final List<Tuple> tupleList = new ArrayList<>();
    tupleList.add(tuple1);
    tupleList.add(tuple2);
    final Predicate predicate1 = new OverlapsBoundingBoxPredicate(new BoundingBox(-100.0, 100.0, -100.0, 100.0));
    final Collection<Tuple> tuples1 = getTuplesFromPredicate(tupleList, predicate1);
    Assert.assertEquals(2, tuples1.size());
    Assert.assertTrue(tuples1.contains(tuple1));
    Assert.assertTrue(tuples1.contains(tuple2));
    final Predicate predicate2 = new OverlapsBoundingBoxPredicate(new BoundingBox(2.0, 100.0, 2.0, 100.0));
    final Collection<Tuple> tuples2 = getTuplesFromPredicate(tupleList, predicate2);
    Assert.assertEquals(1, tuples2.size());
    Assert.assertTrue(tuples2.contains(tuple1));
    Assert.assertFalse(tuples2.contains(tuple2));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Tuple(org.bboxdb.storage.entity.Tuple) Predicate(org.bboxdb.storage.queryprocessor.predicate.Predicate) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 BoundingBox (org.bboxdb.commons.math.BoundingBox)2 Tuple (org.bboxdb.storage.entity.Tuple)2 AndPredicate (org.bboxdb.storage.queryprocessor.predicate.AndPredicate)2 NewerAsVersionTimePredicate (org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate)2 OverlapsBoundingBoxPredicate (org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate)2 Predicate (org.bboxdb.storage.queryprocessor.predicate.Predicate)2 Test (org.junit.Test)2