Search in sources :

Example 1 with CreateListVisitor

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

the class BoundingBoxIntersectsEdgeVisitor method getEdges.

public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final Edge<T> edge, final double maxDistance) {
    final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
    final LineString line = edge.getLineString();
    BoundingBox boundingBox = line.getBoundingBox();
    boundingBox = boundingBox.expand(maxDistance);
    final BoundingBoxIntersectsEdgeVisitor<T> visitor = new BoundingBoxIntersectsEdgeVisitor<>(boundingBox, results);
    final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
    index.forEach(boundingBox, visitor);
    final List<Edge<T>> list = results.getList();
    list.remove(edge);
    return list;
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

Example 2 with CreateListVisitor

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

the class EdgeIntersectsLinearlyEdgeVisitor method getEdges.

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

Example 3 with CreateListVisitor

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

the class EdgeLessThanDistanceToNodeVisitor method edgesWithinDistance.

public static <T> List<Edge<T>> edgesWithinDistance(final Graph<T> graph, final Node<T> node, final double maxDistance) {
    final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
    final Point point = node;
    BoundingBox env = point.getBoundingBox();
    env = env.expand(maxDistance);
    graph.getEdgeIndex().forEach(env, new EdgeLessThanDistanceToNodeVisitor<>(node, maxDistance, results));
    return results.getList();
}
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 4 with CreateListVisitor

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

the class NodeLessThanDistanceOfGeometryVisitor method getNodes.

public static <T> List<Node<T>> getNodes(final Graph<T> graph, final Geometry geometry, final double maxDistance) {
    if (geometry == null) {
        return Collections.emptyList();
    } else {
        final CreateListVisitor<Node<T>> results = new CreateListVisitor<>();
        BoundingBox env = geometry.getBoundingBox();
        env = env.expand(maxDistance);
        final IdObjectIndex<Node<T>> index = graph.getNodeIndex();
        final NodeLessThanDistanceOfGeometryVisitor<T> visitor = new NodeLessThanDistanceOfGeometryVisitor<>(geometry, maxDistance, results);
        index.forEach(env, visitor);
        return results.getList();
    }
}
Also used : Node(com.revolsys.geometry.graph.Node) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor)

Example 5 with CreateListVisitor

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

the class OnLineNodeVisitor method getNodes.

public static <T> List<Node<T>> getNodes(final Graph<T> graph, final LineString line, final double maxDistance) {
    if (line == null) {
        return Collections.emptyList();
    } else {
        final CreateListVisitor<Node<T>> results = new CreateListVisitor<>();
        BoundingBox env = line.getBoundingBox();
        env = env.expand(maxDistance);
        final IdObjectIndex<Node<T>> index = graph.getNodeIndex();
        final OnLineNodeVisitor<T> visitor = new OnLineNodeVisitor<>(line, results);
        index.forEach(env, visitor);
        return results.getList();
    }
}
Also used : Node(com.revolsys.geometry.graph.Node) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor)

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