use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method testIntervalSplit1.
/**
* Test the splitting of intervals
*/
@Test(timeout = 60000)
public void testIntervalSplit1() {
final DoubleInterval interval1 = new DoubleInterval(0, 100);
final DoubleInterval leftPart = interval1.splitAndGetLeftPart(50, true);
final DoubleInterval rightPart = interval1.splitAndGetRightPart(50, true);
Assert.assertTrue(interval1.isBeginIncluded());
Assert.assertTrue(interval1.isEndIncluded());
Assert.assertTrue(leftPart.isBeginIncluded());
Assert.assertTrue(leftPart.isEndIncluded());
Assert.assertTrue(rightPart.isBeginIncluded());
Assert.assertTrue(rightPart.isEndIncluded());
Assert.assertEquals(0, leftPart.getBegin(), 0.0001);
Assert.assertEquals(50, leftPart.getEnd(), 0.0001);
Assert.assertEquals(50, rightPart.getBegin(), 0.0001);
Assert.assertEquals(100, rightPart.getEnd(), 0.0001);
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method testIntersection2.
/**
* Test intersection calculation
*/
@Test(timeout = 60000)
public void testIntersection2() {
final DoubleInterval floatInterval1 = new DoubleInterval(1, 2, false, false);
final DoubleInterval floatInterval2 = new DoubleInterval(2, 3, false, false);
Assert.assertTrue(floatInterval1.getIntersection(floatInterval2) == null);
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method testIntersection1.
/**
* Test intersection calculation
*/
@Test(timeout = 60000)
public void testIntersection1() {
final DoubleInterval floatInterval = new DoubleInterval(1, 2);
Assert.assertTrue(floatInterval.getIntersection(null) == null);
Assert.assertEquals(floatInterval.getIntersection(floatInterval), floatInterval);
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method testIntersection7.
/**
* Test intersection calculation
*/
@Test(timeout = 60000)
public void testIntersection7() {
final DoubleInterval floatInterval1 = new DoubleInterval(1, 2, true, true);
final DoubleInterval floatInterval2 = new DoubleInterval(1, 3, true, true);
Assert.assertEquals(floatInterval1, floatInterval2.getIntersection(floatInterval1));
Assert.assertEquals(floatInterval1, floatInterval1.getIntersection(floatInterval2));
}
use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.
the class TestDoubleInterval method intervalCovered1.
/**
* Test overlap method (closed intervals)
*/
@Test(timeout = 60000)
public void intervalCovered1() {
final DoubleInterval floatInterval1 = new DoubleInterval(1, 100);
final DoubleInterval floatInterval2 = new DoubleInterval(50, 150);
final DoubleInterval floatInterval3 = new DoubleInterval(500, 900);
final DoubleInterval floatInterval4 = new DoubleInterval(100, 101);
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval2));
Assert.assertTrue(floatInterval2.isOverlappingWith(floatInterval1));
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval4));
Assert.assertTrue(floatInterval1.isOverlappingWith(floatInterval1));
Assert.assertTrue(floatInterval2.isOverlappingWith(floatInterval2));
Assert.assertTrue(floatInterval3.isOverlappingWith(floatInterval3));
Assert.assertTrue(floatInterval4.isOverlappingWith(floatInterval4));
Assert.assertFalse(floatInterval1.isOverlappingWith(floatInterval3));
Assert.assertFalse(floatInterval2.isOverlappingWith(floatInterval3));
}
Aggregations