use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class RecordQuadTree method getItems.
@Override
public List<R> getItems(final BoundingBoxProxy boundingBoxProxy) {
final BoundingBox boundingBox = boundingBoxProxy.getBoundingBox();
final List<R> results = super.getItems(boundingBoxProxy);
for (final Iterator<R> iterator = results.iterator(); iterator.hasNext(); ) {
final R record = iterator.next();
final Geometry geometry = record.getGeometry();
if (geometry == null) {
iterator.remove();
} else {
final BoundingBox recordBoundingBox = geometry.getBoundingBox();
if (!boundingBox.intersects(recordBoundingBox)) {
iterator.remove();
}
}
}
return results;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class RTreeLeaf method updateEnvelope.
@Override
protected void updateEnvelope() {
double minX = Double.MAX_VALUE;
double maxX = -Double.MAX_VALUE;
double minY = Double.MAX_VALUE;
double maxY = -Double.MAX_VALUE;
for (int i = 0; i < this.size; i++) {
final BoundingBox objectBounds = this.objectBoundingBoxes[i];
final double nodeMinX = objectBounds.getMinX();
if (nodeMinX < minX) {
minX = nodeMinX;
}
final double nodeMinY = objectBounds.getMinY();
if (nodeMinY < minY) {
minY = nodeMinY;
}
final double nodeMaxX = objectBounds.getMaxX();
if (nodeMaxX > maxX) {
maxX = nodeMaxX;
}
final double nodeMaxY = objectBounds.getMaxY();
if (nodeMaxY > maxY) {
maxY = nodeMaxY;
}
}
setBoundingBox(minX, minY, maxX, maxY);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class RTreeLeaf method split.
public List<RTreeNode<T>> split(final T object, final BoundingBox objectBoundingBox) {
final RTreeLeaf<T> leaf1 = new RTreeLeaf<>(this.objects.length);
final RTreeLeaf<T> leaf2 = new RTreeLeaf<>(this.objects.length);
// TODO Add some ordering to the results
final int midPoint = (int) Math.ceil(this.size / 2.0);
for (int i = 0; i <= midPoint; i++) {
final BoundingBox objectBounds = this.objectBoundingBoxes[i];
final T object1 = this.objects[i];
leaf1.add(objectBounds, object1);
}
for (int i = midPoint + 1; i < this.size; i++) {
final BoundingBox objectBounds = this.objectBoundingBoxes[i];
final T object1 = this.objects[i];
leaf2.add(objectBounds, object1);
}
leaf2.add(objectBoundingBox, object);
return Arrays.<RTreeNode<T>>asList(leaf1, leaf2);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class GeometrySegmentQuadTree method intersectsBounds.
@Override
protected boolean intersectsBounds(final Object id, final double x, final double y) {
final Segment segment = getItem(id);
final BoundingBox boundingBox = segment.getBoundingBox();
return boundingBox.intersects(x, y, x, y);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class GeometrySegmentQuadTree method getWithinDistance.
public List<Segment> getWithinDistance(final Point point, final double maxDistance) {
BoundingBox boundingBox = point.getBoundingBox();
boundingBox = boundingBox.expand(maxDistance);
final LineSegmentCoordinateDistanceFilter filter = new LineSegmentCoordinateDistanceFilter(point, maxDistance);
return getItems(boundingBox, filter);
}
Aggregations