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