Search in sources :

Example 26 with DoubleInterval

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);
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 27 with DoubleInterval

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);
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 28 with DoubleInterval

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);
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 29 with DoubleInterval

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));
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 30 with DoubleInterval

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));
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Aggregations

DoubleInterval (org.bboxdb.commons.math.DoubleInterval)38 Test (org.junit.Test)29 BoundingBox (org.bboxdb.commons.math.BoundingBox)10 ArrayList (java.util.ArrayList)5 List (java.util.List)3 Color (java.awt.Color)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)1 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)1 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)1 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)1