Search in sources :

Example 6 with CreateListVisitor

use of com.revolsys.visitor.CreateListVisitor in project com.revolsys.open by revolsys.

the class EdgeLessThanDistance method getEdges.

public static List<Edge<LineSegment>> getEdges(final Graph<LineSegment> graph, final LineSegment lineSegment, final double maxDistance) {
    final CreateListVisitor<Edge<LineSegment>> results = new CreateListVisitor<>();
    BoundingBox envelope = lineSegment.getBoundingBox();
    envelope = envelope.expand(maxDistance);
    final IdObjectIndex<Edge<LineSegment>> edgeIndex = graph.getEdgeIndex();
    edgeIndex.forEach(envelope, new EdgeLessThanDistance(lineSegment, maxDistance, results));
    return results.getList();
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

Example 7 with CreateListVisitor

use of com.revolsys.visitor.CreateListVisitor in project com.revolsys.open by revolsys.

the class NodeOnEdgeVisitor method getEdges.

public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final Node<T> node, final double maxDistance) {
    final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
    final Point point = node;
    BoundingBox boundingBox = point.getBoundingBox();
    boundingBox = boundingBox.expand(maxDistance);
    final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
    final NodeOnEdgeVisitor<T> visitor = new NodeOnEdgeVisitor<>(node, boundingBox, maxDistance, results);
    index.forEach(boundingBox, visitor);
    final List<Edge<T>> edges = results.getList();
    Collections.sort(edges);
    return edges;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Point(com.revolsys.geometry.model.Point) Edge(com.revolsys.geometry.graph.Edge)

Example 8 with CreateListVisitor

use of com.revolsys.visitor.CreateListVisitor in project com.revolsys.open by revolsys.

the class EdgeIntersectLineVisitor method getEdges.

public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final LineString line) {
    final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
    final BoundingBox env = line.getBoundingBox();
    final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
    index.forEach(env, new EdgeIntersectLineVisitor<>(line, results));
    return results.getList();
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)8 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)8 Edge (com.revolsys.geometry.graph.Edge)6 Node (com.revolsys.geometry.graph.Node)2 LineString (com.revolsys.geometry.model.LineString)2 Point (com.revolsys.geometry.model.Point)2