How to get all self-intersecting points in polygon

60 views
Skip to first unread message

Raimond

unread,
Dec 1, 2017, 4:55:26 PM12/1/17
to NetTopologySuite
Hi,

Maybe someone can help me, how can I get all self-intersection points in polygon?

I wrote this simple C# function:

private void CollectAlIntersections(IGeometry g)
        {
            List<ICoordinate> invalidPoints = new List<ICoordinate>();
            GeometryGraph geomGraph = new GeometryGraph(0, g);
            LineIntersector li = new RobustLineIntersector();
            SegmentIntersector intersector = geomGraph.ComputeSelfNodes(li, true);
            if (intersector.HasProperIntersection)
            {
                ICoordinate invalidPoint = intersector.ProperIntersectionPoint;
                invalidPoints.Add(invalidPoint);
            }
        }

Problem is that I'm always getting only one intersection point althought polygon has at least 4 self-intersecting points. Can anyone help me?

FObermaier

unread,
Jan 24, 2018, 3:28:22 AM1/24/18
to NetTopologySuite
The following lines should work:
private void CollectAllIntersections(IGeometry g, out IList<Coordinate> invalidPoints)
{
    invalidPoints = null;
    var iif = InteriorIntersectionFinder.CreateAllIntersectionsFinder(new RobustLineIntersector());
    var noder = new MCIndexNoder(iif);
    noder.ComputeNodes(SegmentStringUtil.ExtractNodedSegmentStrings(g));
    if (iif.Count > 0)
        invalidPoints = iif.Intersections;
}
Reply all
Reply to author
Forward
0 new messages