Search in sources :

Example 1 with CellGrid

use of org.bboxdb.storage.entity.CellGrid in project bboxdb by jnidzwetzki.

the class TestCellGrid method testCellGridCreation.

/**
 * Test cell grid creation
 */
@Test(timeout = 60000)
public void testCellGridCreation() {
    final CellGrid cellGrid2D1 = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    final CellGrid cellGrid2D2 = CellGrid.buildWithFixedCellSize(new BoundingBox(0.0, 10.0, 0.0, 10.0), 1);
    Assert.assertEquals(cellGrid2D1.getAllCells(), cellGrid2D2.getAllCells());
    Assert.assertEquals(cellGrid2D1, cellGrid2D2);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Example 2 with CellGrid

use of org.bboxdb.storage.entity.CellGrid in project bboxdb by jnidzwetzki.

the class TestCellGrid method testGetCells1.

/**
 * Test the cell creation
 */
@Test(timeout = 60000)
public void testGetCells1() {
    final CellGrid cellGrid1D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0), 10);
    Assert.assertEquals(10, cellGrid1D.getAllCells().size());
    final CellGrid cellGrid2D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(100, cellGrid2D.getAllCells().size());
    final CellGrid cellGrid3D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(1000, cellGrid3D.getAllCells().size());
    final CellGrid cellGrid4D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(10000, cellGrid4D.getAllCells().size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Example 3 with CellGrid

use of org.bboxdb.storage.entity.CellGrid in project bboxdb by jnidzwetzki.

the class TestCellGrid method testGetCells3.

/**
 * Test the cell creation
 */
@Test(expected = IllegalArgumentException.class)
public void testGetCells3() {
    final CellGrid cellGrid2D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(1.5, 1.5, 1.5, 1.5)).size());
    // Wrong dimension
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(10.0, 10.0)).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Example 4 with CellGrid

use of org.bboxdb.storage.entity.CellGrid in project bboxdb by jnidzwetzki.

the class TestFixedGrid method run.

@Override
public void run() {
    System.out.format("Reading %s%n", filename);
    final BoundingBox boundingBox = ExperimentHelper.determineBoundingBox(filename, format);
    for (final Integer cellsPerDimension : cellSizes) {
        System.out.println("Cells per Dimension: " + cellsPerDimension);
        final CellGrid cellGrid = CellGrid.buildWithFixedAmountOfCells(boundingBox, cellsPerDimension);
        runExperiment(cellGrid);
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid)

Example 5 with CellGrid

use of org.bboxdb.storage.entity.CellGrid in project bboxdb by jnidzwetzki.

the class TestCellGrid method testGetCells2.

/**
 * Test the cell creation
 */
@Test(timeout = 60000)
public void testGetCells2() {
    final CellGrid cellGrid2D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(1.5, 1.5, 1.5, 1.5)).size());
    // End pos
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(10.0, 10.0, 10.0, 10.0)).size());
    // Outside
    Assert.assertEquals(0, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(10.1, 10.1, 10.1, 10.1)).size());
    // Grid point
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(1.0, 1.0, 1.0, 1.0)).size());
    // Start point
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(0.0, 0.0, 0.0, 0.0)).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)8 CellGrid (org.bboxdb.storage.entity.CellGrid)8 Test (org.junit.Test)7