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;
}
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;
}
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;
}
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);
}
}
}
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());
}
Aggregations