# Analyzing single Polygon or Polyline that overlaps itself using ArcObjects?

My current process is to determine obstructions in an area and determine properties of those obstructions as they relate to a centre polyline. Per the image below I take a polyline which denotes a flight path. I then buffer the polyline by x units to get an accountability polygon. For each of the points inside the polygon I will determine the lateral distance to the centre line and also the distance along the centre line.

I use ArcObjects against ArcGIS 10.4.1 with a Basic License. My process works great when the flight path is simple. however, when the path is more complex (ie it overlaps itself) I am having difficulty in trying to analyse the scenario.

In its basic format my code looks like this:

``````'For a given point, polyline, and polygon feature class
Dim spatialFilter As ISpatialFilter = New SpatialFilter
spatialFilter.Geometry = pGeomPolygon
spatialFilter.GeometryField = pPointFeatClass.ShapeFieldName
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains

'from the results above I now iterate through the filtered obstruction points
for each ptObs as IPoint in filteredList
'get the point on the line that is closest to ptObs
Dim pntAlongCenterline As IPoint = New Point
Dim distAlongLineToPnt As Double = 0, distFromPntToLine As Double = 0, IsToRightOfLine As Boolean
pPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, ptObs, False, pntAlongCenterline, distAlongLineToPnt, distFromPntToLine, IsToRightOfLine)

'we can think of these two values as the "x" and "y" coordinates of the obstruction if we took the polyline as the axis.
'distAlongLineToPnt is the distance along the centerline where the obstruction is located if we were to draw a perpendicular segment
'distFromPntToLine is the lateral distance from the centerline to the obstruction
next ptObs
``````

The problem arises when the flight path is complex and it overlaps itself. In that case a single obstruction can correspond to two locations on the flight path as I have drawn in the image where the polygon intersects itself. In this case I can't use QueryPointAndDistance as that gives me only one point on the centre line: the closest. That obstruction should be accounted for twice in the flight path but am drawing a blank in how I can process this type of scenario.

• I'd use dissolve polyline to single parts. – FelixIP Sep 20 '18 at 20:22
• Then? I still need to determine to what parts the point will apply to right? – sinDizzy Sep 20 '18 at 20:45
• If you buffer a point by the distance (or just create a circle polygon on it) then intersect the circular polygon with the flightpath polyline, the number of parts returned by the intersect should tell you the number of places along the flight path that the point is close to. – Kirk Kuykendall Sep 20 '18 at 20:59
• That's food for thought. I think it may work in some cases and fail in others. But let me think about this with the suggestion about polyline parts. – sinDizzy Sep 20 '18 at 21:22
• I'd work this using segment buffers, tracking if the "within_distance" state changes from 'no' to 'yes'. This also allows you to determine when the state changes. – Vince Sep 20 '18 at 21:56