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));
}
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));
}
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());
}
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);
}
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);
}
Aggregations