use of com.revolsys.geometry.model.coordinates.filter.CrossingLineSegmentFilter in project com.revolsys.open by revolsys.
the class LineStringGraph method splitCrossingEdges.
public void splitCrossingEdges() {
final Comparator<Edge<LineSegment>> comparator = new EdgeAttributeValueComparator<>(INDEX);
forEachEdge(comparator, (edge) -> {
final LineSegment line1 = edge.getObject();
final Predicate<LineSegment> lineFilter = new CrossingLineSegmentFilter(line1);
final Predicate<Edge<LineSegment>> filter = new EdgeObjectFilter<>(lineFilter);
final List<Edge<LineSegment>> edges = getEdges(line1, filter);
if (!edges.isEmpty()) {
final List<Point> points = new ArrayList<>();
for (final Edge<LineSegment> edge2 : edges) {
final LineSegment line2 = edge2.getObject();
final Geometry intersections = line1.getIntersection(line2);
if (intersections instanceof Point) {
final Point intersection = (Point) intersections;
points.add(intersection);
edge2.split(intersection);
}
}
if (!points.isEmpty()) {
edge.splitEdge(points);
}
}
});
}
Aggregations