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