Search in sources :

Example 21 with DoubleInterval

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

the class TestDoubleInterval method testIntervalSplit4.

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

Example 22 with DoubleInterval

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

the class TestDoubleInterval method testRoundedString.

/**
 * Test the rounded string method
 */
@Test(timeout = 60000)
public void testRoundedString() {
    final DoubleInterval doubleInterval1 = new DoubleInterval(0.4543534d, 0.9423444d, true, true);
    final String toStringValue1 = doubleInterval1.toString();
    final String roundedValue1 = doubleInterval1.getRoundedString(4);
    System.out.println(toStringValue1 + " / " + roundedValue1);
    Assert.assertTrue(toStringValue1.length() > roundedValue1.length());
    final DoubleInterval doubleInterval2 = new DoubleInterval(1.2d, 4.2d, true, true);
    final String toStringValue2 = doubleInterval2.toString();
    final String roundedValue2 = doubleInterval2.getRoundedString(4);
    System.out.println(toStringValue2 + " / " + roundedValue2);
    Assert.assertTrue(toStringValue2.length() >= roundedValue2.length());
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 23 with DoubleInterval

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

the class TestBoundingBoxQuery method executeQueries.

/**
 * Execute the bounding box queries
 * @param maxDimensionSize
 * @param boundingBox
 * @param bboxDBConnection
 * @throws BBoxDBException
 * @throws InterruptedException
 * @throws RejectedException
 */
protected void executeQueries(final double maxDimensionSize, final BoundingBox boundingBox, final BBoxDB bboxDBConnection) throws BBoxDBException, InterruptedException, RejectedException {
    for (int i = 0; i < QUERIES; i++) {
        final List<DoubleInterval> bboxIntervals = new ArrayList<>();
        // Determine query bounding box
        for (int dimension = 0; dimension < boundingBox.getDimension(); dimension++) {
            final double dataExtent = boundingBox.getExtent(dimension);
            final double bboxOffset = (random.nextDouble() % 1) * dataExtent;
            final double coordinateLow = boundingBox.getCoordinateLow(dimension);
            final double coordinateHigh = boundingBox.getCoordinateHigh(dimension);
            final double bboxStartPos = coordinateLow + bboxOffset;
            final double bboxEndPos = Math.min(bboxStartPos + dataExtent * maxDimensionSize, coordinateHigh);
            final DoubleInterval doubleInterval = new DoubleInterval(bboxStartPos, bboxEndPos);
            bboxIntervals.add(doubleInterval);
        }
        final BoundingBox queryBox = new BoundingBox(bboxIntervals);
        final TupleListFuture future = bboxDBConnection.queryBoundingBox(tablename, queryBox);
        pendingFutures.put(future);
    }
    pendingFutures.waitForCompletion();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) ArrayList(java.util.ArrayList) DoubleInterval(org.bboxdb.commons.math.DoubleInterval)

Example 24 with DoubleInterval

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

the class TestBoundingBox method testSize.

/**
 * Test the size
 */
@Test(timeout = 60000)
public void testSize() {
    final BoundingBox boundingBox = new BoundingBox(Arrays.asList(new DoubleInterval(1, 2, true, false)));
    Assert.assertTrue(boundingBox.getSize() > 0);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 25 with DoubleInterval

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

the class TestBoundingBox method testToString.

/**
 * Test the to string method
 */
@Test(timeout = 60000)
public void testToString() {
    final BoundingBox boundingBox = new BoundingBox(Arrays.asList(new DoubleInterval(1, 2, true, false)));
    Assert.assertTrue(boundingBox.toString().length() > 10);
    boundingBox.hashCode();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) 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