Search in sources :

Example 61 with BoundingBox

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;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 62 with BoundingBox

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);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 63 with BoundingBox

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);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 64 with BoundingBox

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);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Segment(com.revolsys.geometry.model.segment.Segment)

Example 65 with BoundingBox

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);
}
Also used : LineSegmentCoordinateDistanceFilter(com.revolsys.geometry.model.coordinates.filter.LineSegmentCoordinateDistanceFilter) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)307 Point (com.revolsys.geometry.model.Point)83 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)76 ArrayList (java.util.ArrayList)45 Geometry (com.revolsys.geometry.model.Geometry)41 LineString (com.revolsys.geometry.model.LineString)26 List (java.util.List)26 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)19 Polygon (com.revolsys.geometry.model.Polygon)14 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)14 Project (com.revolsys.swing.map.layer.Project)14 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)12 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)11 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)11 Edge (com.revolsys.geometry.graph.Edge)10 HashMap (java.util.HashMap)10 Record (com.revolsys.record.Record)9 Graphics2D (java.awt.Graphics2D)9 MapEx (com.revolsys.collection.map.MapEx)8 LinearRing (com.revolsys.geometry.model.LinearRing)8