Search in sources :

Example 1 with DoubleInterval

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

the class QuadtreeSpacePartitioner method createBoundingBoxes.

/**
 * Create a list with bounding boxes
 * @param box
 * @return
 */
private List<BoundingBox> createBoundingBoxes(final BoundingBox box) {
    final List<DoubleInterval> list1 = new ArrayList<>();
    final List<DoubleInterval> list2 = new ArrayList<>();
    generateIntervalLists(box, list1, list2);
    List<List<DoubleInterval>> intervalCombinations = ListHelper.getCombinations(list1, list2);
    final List<BoundingBox> childBoxes = new ArrayList<>();
    for (List<DoubleInterval> boxAsIntervals : intervalCombinations) {
        childBoxes.add(new BoundingBox(boxAsIntervals));
    }
    return childBoxes;
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) DoubleInterval(org.bboxdb.commons.math.DoubleInterval) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with DoubleInterval

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

the class TestDoubleInterval method testIntersection8.

/**
 * Test intersection calculation
 */
@Test(timeout = 60000)
public void testIntersection8() {
    final DoubleInterval floatInterval1 = new DoubleInterval(2, 3, 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 3 with DoubleInterval

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

the class TestDoubleInterval method testIntervalSplit2.

/**
 * Test split at invalid position
 */
@Test(expected = IllegalArgumentException.class)
public void testIntervalSplit2() {
    final DoubleInterval interval1 = new DoubleInterval(0, 100);
    interval1.splitAndGetLeftPart(-10, false);
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 4 with DoubleInterval

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

the class TestDoubleInterval method testToAndFromString1.

/**
 * Test the from and to string method
 */
@Test(timeout = 60000)
public void testToAndFromString1() {
    final DoubleInterval doubleInterval1 = new DoubleInterval(1, 2, false, false);
    final DoubleInterval doubleInterval2 = new DoubleInterval(-1, 2, true, false);
    final DoubleInterval doubleInterval3 = new DoubleInterval(-1.2, 2.3, false, true);
    final DoubleInterval doubleInterval4 = new DoubleInterval(-100, 200, true, true);
    final DoubleInterval doubleInterval5 = new DoubleInterval(DoubleInterval.MIN_VALUE, DoubleInterval.MAX_VALUE, true, true);
    final DoubleInterval doubleInterval6 = new DoubleInterval(DoubleInterval.MIN_VALUE, DoubleInterval.MAX_VALUE, false, false);
    Assert.assertEquals(doubleInterval1, new DoubleInterval(doubleInterval1.toString()));
    Assert.assertEquals(doubleInterval2, new DoubleInterval(doubleInterval2.toString()));
    Assert.assertEquals(doubleInterval3, new DoubleInterval(doubleInterval3.toString()));
    Assert.assertEquals(doubleInterval4, new DoubleInterval(doubleInterval4.toString()));
    Assert.assertEquals(doubleInterval5, new DoubleInterval(doubleInterval5.toString()));
    Assert.assertEquals(doubleInterval6, new DoubleInterval(doubleInterval6.toString()));
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 5 with DoubleInterval

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

the class TestDoubleInterval method coveredPoint1.

/**
 * Test cover method
 */
@Test(timeout = 60000)
public void coveredPoint1() {
    final DoubleInterval floatInterval = new DoubleInterval(1, 100);
    Assert.assertTrue(floatInterval.isBeginIncluded());
    Assert.assertTrue(floatInterval.isEndIncluded());
    Assert.assertTrue(floatInterval.overlapsWith(floatInterval.getBegin(), true));
    Assert.assertTrue(floatInterval.overlapsWith(floatInterval.getEnd(), true));
    Assert.assertFalse(floatInterval.overlapsWith(floatInterval.getBegin(), false));
    Assert.assertFalse(floatInterval.overlapsWith(floatInterval.getEnd(), false));
    Assert.assertTrue(floatInterval.overlapsWith(50, true));
    Assert.assertTrue(floatInterval.overlapsWith(50, false));
    Assert.assertFalse(floatInterval.overlapsWith(-10, true));
    Assert.assertFalse(floatInterval.overlapsWith(110, true));
}
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