Search in sources :

Example 16 with BoundingBoxDoubleXY

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

the class HotPixel method getSafeEnvelope.

/**
 * Returns a "safe" envelope that is guaranteed to contain the hot pixel.
 * The envelope returned will be larger than the exact envelope of the
 * pixel.
 *
 * @return an envelope which contains the hot pixel
 */
public BoundingBox getSafeEnvelope() {
    if (this.safeEnv == null) {
        final double safeTolerance = SAFE_ENV_EXPANSION_FACTOR / this.scaleFactor;
        this.safeEnv = new BoundingBoxDoubleXY(this.originalPt.getX() - safeTolerance, this.originalPt.getY() - safeTolerance, this.originalPt.getX() + safeTolerance, this.originalPt.getY() + safeTolerance);
    }
    return this.safeEnv;
}
Also used : BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 17 with BoundingBoxDoubleXY

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

the class BufferSubgraph method getEnvelope.

/**
 * Computes the envelope of the edges in the subgraph.
 * The envelope is cached after being computed.
 *
 * @return the envelope of the graph.
 */
public BoundingBox getEnvelope() {
    if (this.env == null) {
        double[] bounds = null;
        for (final DirectedEdge dirEdge : this.dirEdgeList) {
            final Edge edge = dirEdge.getEdge();
            final LineString points = edge.getLineString();
            for (int i = 0; i < points.getVertexCount(); i++) {
                final Point point = points.getPoint(i);
                if (bounds == null) {
                    bounds = RectangleUtil.newBounds(2, point);
                } else {
                    RectangleUtil.expand(bounds, 2, point);
                }
            }
        }
        this.env = new BoundingBoxDoubleXY(bounds);
    }
    return this.env;
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Point(com.revolsys.geometry.model.Point)

Example 18 with BoundingBoxDoubleXY

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

the class IndexTester method newGridItems.

public static List newGridItems(final int nGridCells) {
    final ArrayList items = new ArrayList();
    int gridSize = (int) Math.sqrt(nGridCells);
    gridSize += 1;
    final double extent = EXTENT_MAX - EXTENT_MIN;
    final double gridInc = extent / gridSize;
    final double cellSize = gridInc;
    for (int i = 0; i < gridSize; i++) {
        for (int j = 0; j < gridSize; j++) {
            final double x = EXTENT_MIN + gridInc * i;
            final double y = EXTENT_MIN + gridInc * j;
            final BoundingBox env = new BoundingBoxDoubleXY(x, y, x + cellSize, y + cellSize);
            items.add(env);
        }
    }
    return items;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 19 with BoundingBoxDoubleXY

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

the class IndexTester method queryGrid.

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

Example 20 with BoundingBoxDoubleXY

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

the class KdTreeTest method testSinglePoint.

@Test
public void testSinglePoint() {
    final KdTree index = new KdTree();
    final KdNode node1 = index.insertPoint(1, 1);
    final KdNode node2 = index.insertPoint(new PointDoubleXY(1, 1));
    Assert.assertSame("Inserting 2 identical points should create one node", node1, node2);
    final BoundingBox queryEnv = new BoundingBoxDoubleXY(0, 0, 10, 10);
    final List<KdNode> result = index.getItems(queryEnv);
    Assert.assertEquals(1, result.size());
    final KdNode node = result.get(0);
    Assert.assertEquals(2, node.getCount());
    Assert.assertTrue(node.isRepeated());
}
Also used : KdTree(com.revolsys.geometry.index.kdtree.KdTree) BoundingBox(com.revolsys.geometry.model.BoundingBox) KdNode(com.revolsys.geometry.index.kdtree.KdNode) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY) Test(org.junit.Test)

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