Search in sources :

Example 1 with BoundingBoxDoubleXY

use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.

the class QuadtreeCorrectTest method newGrid.

void newGrid(final int nGridCells) {
    int gridSize = (int) Math.sqrt(nGridCells);
    gridSize += 1;
    final double extent = MAX_EXTENT - MIN_EXTENT;
    final double gridInc = extent / gridSize;
    final double cellSize = 2 * gridInc;
    for (int i = 0; i < gridSize; i++) {
        for (int j = 0; j < gridSize; j++) {
            final double x = MIN_EXTENT + gridInc * i;
            final double y = MIN_EXTENT + gridInc * j;
            final BoundingBox env = new BoundingBoxDoubleXY(x, y, x + cellSize, y + cellSize);
            this.index.insertItem(env, env);
            this.envList.add(env);
        }
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 2 with BoundingBoxDoubleXY

use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.

the class SpatialIndexTester method addSourceData.

private void addSourceData(final double offset, final List<BoundingBox> sourceData) {
    for (int i = 0; i < CELLS_PER_GRID_SIDE; i++) {
        final double minx = i * CELL_EXTENT + offset;
        final double maxx = minx + FEATURE_EXTENT;
        for (int j = 0; j < CELLS_PER_GRID_SIDE; j++) {
            final double miny = j * CELL_EXTENT + offset;
            final double maxy = miny + FEATURE_EXTENT;
            final BoundingBox e = new BoundingBoxDoubleXY(minx, miny, maxx, maxy);
            sourceData.add(e);
        }
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 3 with BoundingBoxDoubleXY

use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.

the class GridGenerator method newBoundingBox.

/**
 * @return BoundingBox
 *
 * @see com.revolsys.geometry.testold.generator.GeometryGenerator#newIterator()
 *
 * @throws NoSuchElementException when all the grids have been created
 * @throws NullPointerException when either the Geometry Factory, or the Bounding Box are undefined.
 */
public BoundingBox newBoundingBox() {
    if (!canCreate()) {
        throw new NoSuchElementException("There are not any grids left to create.");
    }
    if (this.geometryFactory == null) {
        throw new NullPointerException("GeometryFactoryI is not declared");
    }
    if (this.boundingBox == null || this.boundingBox.isEmpty()) {
        throw new NullPointerException("Bounding Box is not declared");
    }
    // base x
    final double x = this.boundingBox.getMinX();
    final double dx = this.boundingBox.getMaxX() - x;
    // base y
    final double y = this.boundingBox.getMinY();
    final double dy = this.boundingBox.getMaxY() - y;
    final int row = this.numberRows == 1 ? 0 : this.index / this.numberRows;
    final int col = this.numberColumns == 1 ? 0 : this.index % this.numberColumns;
    // size of a step
    double sx, sy;
    sx = dx / this.numberColumns;
    sy = dy / this.numberRows;
    double minx, miny;
    minx = x + col * sx;
    miny = y + row * sy;
    final BoundingBox box = new BoundingBoxDoubleXY(this.geometryFactory.makePrecise(0, minx), this.geometryFactory.makePrecise(1, miny), this.geometryFactory.makePrecise(0, minx + sx), this.geometryFactory.makePrecise(1, miny + sy));
    this.index++;
    return box;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with BoundingBoxDoubleXY

use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.

the class STRtreeTest method testEmptyTreeUsingItemVisitorQuery.

public void testEmptyTreeUsingItemVisitorQuery() {
    final StrTree tree = new StrTree();
    tree.query(new BoundingBoxDoubleXY(0, 1, 0, 1), (item) -> {
        assertTrue("Should never reach here", true);
    });
}
Also used : StrTree(com.revolsys.geometry.index.strtree.StrTree) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 5 with BoundingBoxDoubleXY

use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.

the class STRtreeTest method testEmptyTreeUsingListQuery.

public void testEmptyTreeUsingListQuery() {
    final StrTree tree = new StrTree();
    final List list = tree.getItems(new BoundingBoxDoubleXY(0, 1, 0, 1));
    assertTrue(list.isEmpty());
}
Also used : StrTree(com.revolsys.geometry.index.strtree.StrTree) ArrayList(java.util.ArrayList) List(java.util.List) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Aggregations

BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)26 BoundingBox (com.revolsys.geometry.model.BoundingBox)18 ArrayList (java.util.ArrayList)7 List (java.util.List)6 Point (com.revolsys.geometry.model.Point)5 Geometry (com.revolsys.geometry.model.Geometry)4 StrTree (com.revolsys.geometry.index.strtree.StrTree)3 KdNode (com.revolsys.geometry.index.kdtree.KdNode)2 KdTree (com.revolsys.geometry.index.kdtree.KdTree)2 LineString (com.revolsys.geometry.model.LineString)2 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Iterator (java.util.Iterator)2 Lists (com.revolsys.collection.list.Lists)1 MapEx (com.revolsys.collection.map.MapEx)1 ScaledIntegerTriangulatedIrregularNetwork (com.revolsys.elevation.tin.compactbinary.ScaledIntegerTriangulatedIrregularNetwork)1 AsciiTin (com.revolsys.elevation.tin.tin.AsciiTin)1 RayCrossingCounter (com.revolsys.geometry.algorithm.RayCrossingCounter)1 Area (com.revolsys.geometry.cs.Area)1 Authority (com.revolsys.geometry.cs.Authority)1 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)1