Polygon - line intersection problem

2832
5
06-04-2013 01:30 AM
ThomasLaue
New Contributor II
Hello,

I am facing a problem when trying to find intersection points between a donut like polygon and a line using ITopologicalOperator.Intersect method:

   // The polygon has already been casted to ITopologicalOperator4 outside the method
   private static IPointCollection5 ComputeIntersectionPoints(ITopologicalOperator4 topologialOperator, ILine normalLine) {
            object obj = Type.Missing;

            ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
            segCollection.AddSegment((ISegment)normalLine, ref obj, ref obj);
            IGeometry resultingGeometry = segCollection as IGeometry;

            topologialOperator.Simplify();
            var intersectionPoints = topologialOperator.Intersect(resultingGeometry, esriGeometryDimension.esriGeometry0Dimension);
            return intersectionPoints.IsEmpty ? new Point() as IPointCollection5 : (IPointCollection5)intersectionPoints;
   }


I am receiving a successful intersection (intersection point) on the other boundary of the polygon but I do not get a hit on the interior border (the result of topologialOperator.Intersect(...) is always null). I have attached a sketch showing the situation. The line starts within the polygon and crosses either the exterior or interior border.

Does anyone can tell me why I do not get the second intersection point. Any help would be very much appreciated! Thank you very much!
0 Kudos
5 Replies
WeifengHe
Esri Contributor
Try the following steps in your code.

1.  I don't know where the data source for the input donut polygon, so before you call Simplify, set the property IsKnownSimple to false.

2.  The 0 dimensional output for intersection call is of MultiPoint type, instead of Point type.
0 Kudos
ThomasLaue
New Contributor II
Hello,

thank you very much for your answer. Unfortunately, setting the "IsKnownSimple" property to "false" does  solve this problem. The return type is implicitly set to "MultiPoint" and works quite well for other intersection tasks.

Does anyone has another idea?
0 Kudos
DuncanHornby
MVP Notable Contributor
Thomas,

Are you using 10.1? Are these lines horizontal or vertical? If so it may be related to this bug introduced by ESRI in 10.1.

Duncan

p.s. You should always state your version of ArcGIS as it helps us help you.
0 Kudos
ThomasLaue
New Contributor II
I am using ArcObjects 10.0 and these lines are not necessarily vertical or horizontal so that I am assuming that my problem is not related to this specific bug.
0 Kudos
WeifengHe
Esri Contributor
The bug Duncan mentioned only applies to Polyline/Polyline intersection.

I just verfied that intersection works with donut-like polygon.  Can you please check the output after you set IsKnownSimple = falase and Simplify?  Is this one still with an interior ring?
0 Kudos