use of com.revolsys.geometry.graph.comparator.NodeDistanceComparator in project com.revolsys.open by revolsys.
the class Graph method findNodes.
/**
* Find all the nodes <= the distance of the edge, that are "on" the line.
*
* @param edge The edge.
* @param distance The distance.
* @return The nodes
* @see IsPointOnLineEdgeFilter
*/
public List<Node<T>> findNodes(final Edge<T> edge, final double distance) {
final IsPointOnLineEdgeFilter<T> filter = new IsPointOnLineEdgeFilter<>(edge, distance);
final Node<T> fromNode = edge.getFromNode();
final Comparator<Node<T>> comparator = new NodeDistanceComparator<>(fromNode);
final BoundingBox boundingBox = filter.getEnvelope();
return getNodes(boundingBox, filter, comparator);
}
use of com.revolsys.geometry.graph.comparator.NodeDistanceComparator in project com.revolsys.open by revolsys.
the class LineStringGraph method getPointsOnEdges.
public Map<Edge<LineSegment>, List<Node<LineSegment>>> getPointsOnEdges(final Graph<LineSegment> graph1, final double tolerance) {
final Map<Edge<LineSegment>, List<Node<LineSegment>>> pointsOnEdge1 = new HashMap<>();
for (final Edge<LineSegment> edge : getEdges()) {
final Node<LineSegment> fromNode = edge.getFromNode();
final Node<LineSegment> toNode = edge.getToNode();
final LineSegment lineSegment = edge.getObject();
final PointOnLineSegment coordinatesFilter = new PointOnLineSegment(lineSegment, tolerance);
final NodeCoordinatesFilter<LineSegment> nodeFilter = new NodeCoordinatesFilter<>(coordinatesFilter);
final NodeDistanceComparator<LineSegment> comparator = new NodeDistanceComparator<>(fromNode);
final List<Node<LineSegment>> nodes = graph1.getNodes(nodeFilter, comparator);
for (final Iterator<Node<LineSegment>> iterator = nodes.iterator(); iterator.hasNext(); ) {
final Node<LineSegment> node = iterator.next();
if (node.equals(2, fromNode)) {
iterator.remove();
} else if (node.equals(2, toNode)) {
iterator.remove();
}
}
if (!nodes.isEmpty()) {
pointsOnEdge1.put(edge, nodes);
}
}
return pointsOnEdge1;
}
Aggregations