Search in sources :

Example 76 with BoundingBox

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

the class TestBoundingBox method testIntersection2.

/**
 * Test the intersection of two bounding boxes
 */
@Test(timeout = 60000)
public void testIntersection2() {
    final BoundingBox boundingBox = new BoundingBox(1d, 3d, 3d, 7d);
    Assert.assertEquals(boundingBox, boundingBox.getIntersection(boundingBox));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 77 with BoundingBox

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

the class TestBoundingBox method testFromAndToByteArray.

/**
 * Test from and to byte array
 */
@Test(timeout = 60000)
public void testFromAndToByteArray() {
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d, 3d, 4d);
    final byte[] bytes = boundingBox1.toByteArray();
    final BoundingBox boundingBox2 = BoundingBox.fromByteArray(bytes);
    Assert.assertEquals(boundingBox1, boundingBox2);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 78 with BoundingBox

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

the class TestBoundingBox method testCompareTo.

/**
 * Test the compare to method
 */
@Test(timeout = 60000)
public void testCompareTo() {
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d, 3d, 4d);
    final BoundingBox boundingBox2 = new BoundingBox(1d, 2d);
    Assert.assertEquals(0, boundingBox1.compareTo(boundingBox1));
    Assert.assertTrue(boundingBox1.compareTo(boundingBox2) > 0);
    Assert.assertTrue(boundingBox2.compareTo(boundingBox1) < 0);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 79 with BoundingBox

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

the class TestBoundingBox method testOverlapping2D.

/**
 * Test the overlapping in 2d
 */
@Test(timeout = 60000)
public void testOverlapping2D() {
    final BoundingBox bb1left = new BoundingBox(0d, 1d, 0d, 1d);
    final BoundingBox bb1leftinside = new BoundingBox(0.5d, 0.7d, 0.5d, 0.7d);
    Assert.assertTrue(bb1left.overlaps(bb1leftinside));
    Assert.assertTrue(bb1leftinside.overlaps(bb1left));
    final BoundingBox bb1middle = new BoundingBox(0.5d, 1.5d, 0.5d, 1.5d);
    Assert.assertTrue(bb1left.overlaps(bb1middle));
    Assert.assertTrue(bb1middle.overlaps(bb1left));
    final BoundingBox bb1right = new BoundingBox(1d, 2d, 10d, 11d);
    Assert.assertFalse(bb1left.overlaps(bb1right));
    Assert.assertFalse(bb1right.overlaps(bb1left));
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 80 with BoundingBox

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

the class DistributionRegionComponent method getToolTipText.

/**
 * Get the tooltip text
 * @return
 */
public String getToolTipText() {
    final StringBuilder sb = new StringBuilder("<html>");
    try {
        final Map<BBoxDBInstance, Map<String, Long>> statistics = addStatisticsToTooltip(sb);
        final BoundingBox boundingBox = distributionRegion.getConveringBox();
        for (int i = 0; i < boundingBox.getDimension(); i++) {
            final DoubleInterval floatInterval = boundingBox.getIntervalForDimension(i);
            sb.append("Dimension: " + i + " ");
            sb.append(floatInterval.toString());
            sb.append("<br>");
        }
        final Collection<BBoxDBInstance> systems = distributionRegion.getSystems();
        for (final BBoxDBInstance instance : systems) {
            if (!statistics.keySet().contains(instance)) {
                sb.append("System: ");
                sb.append(instance.toGUIString(guiModel.isScreenshotMode()));
                sb.append(" <br>");
            }
        }
        final boolean mergeableByZookeeper = RegionMergeHelper.isMergingByZookeeperAllowed(distributionRegion);
        final boolean mergeableBySpacePartitioner = RegionMergeHelper.isMergingBySpacePartitionerAllowed(distributionRegion);
        sb.append("Merge supported by configuration <i>" + mergeableByZookeeper + "</i>, by space partitioner <i>" + mergeableBySpacePartitioner + "</i><br>");
        final boolean isSplitSupported = RegionSplitHelper.isSplittingSupported(distributionRegion);
        sb.append("Split supported by space partitioner <i>" + isSplitSupported + "</i><br>");
    } catch (Exception e) {
        logger.error("Got an exception while reading statistics for distribution group", e);
    }
    sb.append("</html>");
    return sb.toString();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DoubleInterval(org.bboxdb.commons.math.DoubleInterval) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Map(java.util.Map) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)194 Test (org.junit.Test)113 Tuple (org.bboxdb.storage.entity.Tuple)61 ArrayList (java.util.ArrayList)25 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)24 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)23 BBoxDBException (org.bboxdb.misc.BBoxDBException)22 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)20 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)16 List (java.util.List)15 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)13 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)13 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)11 IOException (java.io.IOException)10 Date (java.util.Date)10 DoubleInterval (org.bboxdb.commons.math.DoubleInterval)10 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)10