Search in sources :

Example 66 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestBoundingBox method testOverlapping3D.

/**
 * Test the overlapping in 3d
 */
@Test(timeout = 60000)
public void testOverlapping3D() {
    final BoundingBox bb1left = new BoundingBox(0d, 1d, 0d, 1d, 0d, 1d);
    final BoundingBox bb1leftinside = new BoundingBox(0.5d, 0.7d, 0.5d, 0.7d, 0.5d, 0.7d);
    Assert.assertTrue(bb1left.overlaps(bb1leftinside));
    Assert.assertTrue(bb1leftinside.overlaps(bb1left));
    final BoundingBox bb1middle = new BoundingBox(0.5d, 1.5d, 0.5d, 1.5d, 0.5d, 1.5d);
    Assert.assertTrue(bb1left.overlaps(bb1middle));
    Assert.assertTrue(bb1middle.overlaps(bb1left));
    final BoundingBox bb1right = new BoundingBox(10d, 11d, 10d, 11d, 10d, 11d);
    Assert.assertFalse(bb1left.overlaps(bb1right));
    Assert.assertFalse(bb1right.overlaps(bb1left));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 67 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestBoundingBox method testBoundingBoxSorting.

/**
 * Test the comparable interface of the bounding box
 */
@Test(timeout = 60000)
public void testBoundingBoxSorting() {
    final BoundingBox boundingBox1 = new BoundingBox(1d, 3d, 3d, 7d);
    final BoundingBox boundingBox2 = new BoundingBox(-1d, 1d, 3d, 7d);
    final BoundingBox boundingBox3 = new BoundingBox(5d, 7d, 3d, 7d);
    final BoundingBox boundingBox4 = new BoundingBox(-11d, -9d, 3d, 7d);
    final BoundingBox boundingBox5 = new BoundingBox(-11d, -9d, -1d, 3d);
    final List<BoundingBox> boundingBoxList = new ArrayList<BoundingBox>();
    boundingBoxList.add(boundingBox1);
    boundingBoxList.add(boundingBox2);
    boundingBoxList.add(boundingBox3);
    boundingBoxList.add(boundingBox4);
    boundingBoxList.add(boundingBox5);
    Collections.sort(boundingBoxList);
    Assert.assertEquals(boundingBox5, boundingBoxList.get(0));
    Assert.assertEquals(boundingBox4, boundingBoxList.get(1));
    Assert.assertEquals(boundingBox2, boundingBoxList.get(2));
    Assert.assertEquals(boundingBox1, boundingBoxList.get(3));
    Assert.assertEquals(boundingBox3, boundingBoxList.get(4));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 68 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestBoundingBox method testDimension.

/**
 * Test the dimension of the bounding box
 */
@Test(timeout = 60000)
public void testDimension() {
    final BoundingBox bb1 = new BoundingBox();
    Assert.assertEquals(0, bb1.getDimension());
    final BoundingBox bb2 = new BoundingBox(1d, 10d);
    Assert.assertEquals(1, bb2.getDimension());
    final BoundingBox bb3 = new BoundingBox(1d, 10d, 10d, 50d);
    Assert.assertEquals(2, bb3.getDimension());
    final BoundingBox bb4 = new BoundingBox(1d, 10d, 10d, 50d, 10d, 10d);
    Assert.assertEquals(3, bb4.getDimension());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 69 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestBoundingBox method testCoverBoundingBox1.

/**
 * Test the creation of the covering bounding box
 */
@Test(timeout = 60000)
public void testCoverBoundingBox1() {
    final BoundingBox boundingBox1 = new BoundingBox(1d, 3d, 1d, 3d);
    final BoundingBox boundingBox2 = new BoundingBox(1d, 4d, 1d, 4d);
    final BoundingBox boundingBox3 = new BoundingBox(1d, 4d, 1d, 4d, 1d, 4d);
    final BoundingBox boundingBox4 = new BoundingBox(-1d, 2d, -1d, 2d, -1d, 2d);
    final BoundingBox boundingBoxResult1 = BoundingBox.getCoveringBox();
    Assert.assertEquals(BoundingBox.FULL_SPACE, boundingBoxResult1);
    Assert.assertEquals(boundingBox1, BoundingBox.getCoveringBox(boundingBox1));
    Assert.assertEquals(boundingBox2, BoundingBox.getCoveringBox(boundingBox2));
    Assert.assertEquals(boundingBox3, BoundingBox.getCoveringBox(boundingBox3));
    Assert.assertEquals(boundingBox4, BoundingBox.getCoveringBox(boundingBox4));
    final BoundingBox boundingBoxResult2 = BoundingBox.getCoveringBox(boundingBox1, boundingBox2);
    Assert.assertEquals(2, boundingBoxResult2.getDimension());
    Assert.assertEquals(boundingBoxResult2, boundingBox2);
    final BoundingBox boundingBoxResult4 = BoundingBox.getCoveringBox(boundingBox3, boundingBox4);
    Assert.assertEquals(3, boundingBoxResult4.getDimension());
    Assert.assertEquals(-1.0d, boundingBoxResult4.getCoordinateLow(0), EQUALS_DELTA);
    Assert.assertEquals(4.0d, boundingBoxResult4.getCoordinateHigh(0), EQUALS_DELTA);
    Assert.assertEquals(-1.0d, boundingBoxResult4.getCoordinateLow(1), EQUALS_DELTA);
    Assert.assertEquals(4.0d, boundingBoxResult4.getCoordinateHigh(1), EQUALS_DELTA);
    Assert.assertEquals(-1.0d, boundingBoxResult4.getCoordinateLow(2), EQUALS_DELTA);
    Assert.assertEquals(4.0d, boundingBoxResult4.getCoordinateHigh(2), EQUALS_DELTA);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 70 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestBoundingBox method testMergeBoxes0.

/**
 * Test merge on array
 */
@Test(timeout = 60000)
public void testMergeBoxes0() {
    final BoundingBox resultBox = BoundingBox.getCoveringBox();
    Assert.assertEquals(BoundingBox.FULL_SPACE, resultBox);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)194 Test (org.junit.Test)113 Tuple (org.bboxdb.storage.entity.Tuple)61 ArrayList (java.util.ArrayList)25 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)24 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)23 BBoxDBException (org.bboxdb.misc.BBoxDBException)22 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)20 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)16 List (java.util.List)15 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)13 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)13 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)11 IOException (java.io.IOException)10 Date (java.util.Date)10 DoubleInterval (org.bboxdb.commons.math.DoubleInterval)10 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)10