Search in sources :

Example 36 with DoubleInterval

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

the class SamplingBasedSplitStrategy method preprocessSamples.

/**
 * Preprocess the samples
 * @param splitDimension
 * @param coveringBox
 * @return
 */
private List<Double> preprocessSamples(final int splitDimension, final BoundingBox coveringBox) {
    final List<Double> pointSamples = new ArrayList<>();
    for (final BoundingBox sampleBox : samples) {
        // Add the begin and end pos to the lists, if the begin / end is in the
        // covering box
        final DoubleInterval tupleInterval = sampleBox.getIntervalForDimension(splitDimension);
        final DoubleInterval groupInterval = coveringBox.getIntervalForDimension(splitDimension);
        if (groupInterval.isPointIncluded(tupleInterval.getBegin())) {
            pointSamples.add(tupleInterval.getBegin());
        }
        if (groupInterval.isPointIncluded(tupleInterval.getEnd())) {
            pointSamples.add(tupleInterval.getEnd());
        }
    }
    logger.info("Samples list has a size of {}, usable elements {}", samples.size(), pointSamples.size());
    return pointSamples;
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) DoubleInterval(org.bboxdb.commons.math.DoubleInterval)

Example 37 with DoubleInterval

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

the class SimpleSplitStrategy method getSplitPoint.

/**
 * Perform a split of the given distribution region
 */
@Override
public double getSplitPoint(final int splitDimension, final BoundingBox coveringBox) {
    // Split region
    final DoubleInterval interval = coveringBox.getIntervalForDimension(splitDimension);
    logger.info("Split at dimension:" + splitDimension + " interval: " + interval);
    return interval.getMidpoint();
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval)

Example 38 with DoubleInterval

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

the class QuadtreeSpacePartitioner method generateIntervalLists.

/**
 * Generate the interval lists
 * @param box
 * @param list1
 * @param list2
 */
private void generateIntervalLists(final BoundingBox box, final List<DoubleInterval> list1, final List<DoubleInterval> list2) {
    for (int dimension = 0; dimension < box.getDimension(); dimension++) {
        final DoubleInterval interval = box.getIntervalForDimension(dimension);
        final double midpoint = interval.getMidpoint();
        final DoubleInterval interval1 = interval.splitAndGetLeftPart(midpoint, false);
        list1.add(interval1);
        final DoubleInterval interval2 = interval.splitAndGetRightPart(midpoint, true);
        list2.add(interval2);
    }
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval)

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