use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestBoundingBox method testFromToString1.
/**
* Test the from and to string method
*/
@Test(timeout = 60000)
public void testFromToString1() {
final BoundingBox boundingBox1 = BoundingBox.FULL_SPACE;
final BoundingBox boundingBox2 = new BoundingBox(0d, 1d);
final BoundingBox boundingBox3 = new BoundingBox(-5d, 5d, -5d, 5d);
final BoundingBox boundingBox4 = new BoundingBox(Arrays.asList(new DoubleInterval(1, 2, false, false)));
final BoundingBox boundingBox5 = new BoundingBox(Arrays.asList(new DoubleInterval(1, 2, false, true)));
final BoundingBox boundingBox6 = new BoundingBox(Arrays.asList(new DoubleInterval(1, 2, true, false)));
final BoundingBox boundingBox7 = new BoundingBox(Arrays.asList(new DoubleInterval(1, 2, true, false), new DoubleInterval(1, 2, false, false)));
final BoundingBox boundingBox8 = BoundingBox.createFullCoveringDimensionBoundingBox(3);
Assert.assertEquals(boundingBox1, new BoundingBox(boundingBox1.toCompactString()));
Assert.assertEquals(boundingBox2, new BoundingBox(boundingBox2.toCompactString()));
Assert.assertEquals(boundingBox3, new BoundingBox(boundingBox3.toCompactString()));
Assert.assertEquals(boundingBox4, new BoundingBox(boundingBox4.toCompactString()));
Assert.assertEquals(boundingBox5, new BoundingBox(boundingBox5.toCompactString()));
Assert.assertEquals(boundingBox6, new BoundingBox(boundingBox6.toCompactString()));
Assert.assertEquals(boundingBox7, new BoundingBox(boundingBox7.toCompactString()));
Assert.assertEquals(boundingBox8, new BoundingBox(boundingBox8.toCompactString()));
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method testIntervalSplit3.
/**
* Test split at invalid position
*/
@Test(expected = IllegalArgumentException.class)
public void testIntervalSplit3() {
final DoubleInterval interval1 = new DoubleInterval(0, 100);
interval1.splitAndGetLeftPart(101, false);
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method testIsCovered2.
/**
* The the covering method
*/
@Test(timeout = 60000)
public void testIsCovered2() {
final DoubleInterval floatInterval1 = new DoubleInterval(1, 2, true, true);
final DoubleInterval floatInterval2 = new DoubleInterval(1, 2, false, false);
final DoubleInterval floatInterval3 = new DoubleInterval(1, 2, false, true);
final DoubleInterval floatInterval4 = new DoubleInterval(1, 2, true, false);
Assert.assertTrue(floatInterval1.isCovering(floatInterval1));
Assert.assertTrue(floatInterval1.isCovering(floatInterval2));
Assert.assertTrue(floatInterval1.isCovering(floatInterval3));
Assert.assertTrue(floatInterval1.isCovering(floatInterval4));
Assert.assertFalse(floatInterval2.isCovering(floatInterval1));
Assert.assertTrue(floatInterval2.isCovering(floatInterval2));
Assert.assertFalse(floatInterval2.isCovering(floatInterval3));
Assert.assertFalse(floatInterval2.isCovering(floatInterval4));
Assert.assertFalse(floatInterval3.isCovering(floatInterval1));
Assert.assertTrue(floatInterval3.isCovering(floatInterval2));
Assert.assertTrue(floatInterval1.isCovering(floatInterval3));
Assert.assertFalse(floatInterval3.isCovering(floatInterval4));
Assert.assertFalse(floatInterval4.isCovering(floatInterval1));
Assert.assertTrue(floatInterval4.isCovering(floatInterval2));
Assert.assertFalse(floatInterval4.isCovering(floatInterval3));
Assert.assertTrue(floatInterval1.isCovering(floatInterval4));
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method intervalConvered3.
/**
* Test overlap method (half open intervals)
*/
@Test(timeout = 60000)
public void intervalConvered3() {
final DoubleInterval floatInterval1 = new DoubleInterval(1, 100, false, true);
final DoubleInterval floatInterval2 = new DoubleInterval(50, 150, false, true);
final DoubleInterval floatInterval3 = new DoubleInterval(0, 101, false, true);
final DoubleInterval floatInterval4 = new DoubleInterval(100, 101, false, true);
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval2));
Assert.assertTrue(floatInterval2.isOverlappingWith(floatInterval1));
Assert.assertFalse(floatInterval1.isOverlappingWith(floatInterval4));
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval3));
Assert.assertTrue(floatInterval3.isOverlappingWith(floatInterval1));
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval1));
Assert.assertTrue(floatInterval2.isOverlappingWith(floatInterval2));
Assert.assertTrue(floatInterval3.isOverlappingWith(floatInterval3));
Assert.assertTrue(floatInterval4.isOverlappingWith(floatInterval4));
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method intervalConvered4.
/**
* Test overlap method (half open intervals)
*/
@Test(timeout = 60000)
public void intervalConvered4() {
final DoubleInterval floatInterval1 = new DoubleInterval(1, 100, true, false);
final DoubleInterval floatInterval2 = new DoubleInterval(50, 150, true, false);
final DoubleInterval floatInterval3 = new DoubleInterval(0, 101, true, false);
final DoubleInterval floatInterval4 = new DoubleInterval(100, 101, true, false);
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval2));
Assert.assertTrue(floatInterval2.isOverlappingWith(floatInterval1));
Assert.assertFalse(floatInterval1.isOverlappingWith(floatInterval4));
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval3));
Assert.assertTrue(floatInterval3.isOverlappingWith(floatInterval1));
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval1));
Assert.assertTrue(floatInterval2.isOverlappingWith(floatInterval2));
Assert.assertTrue(floatInterval3.isOverlappingWith(floatInterval3));
Assert.assertTrue(floatInterval4.isOverlappingWith(floatInterval4));
}
Aggregations