Finding polygons to left or right of line

2260
2
Jump to solution
08-04-2014 11:28 AM
MarkParr
New Contributor

I am playing around with some C# logic to spin line segments indicating if polygons are on the left or right of the line segment.  I am using ISpatialFilter and esriSpatialRelEnum.esriSpatialRelTouches relationship to find polygons that touch a line segment.  I have seen references to the HitTest method to determine left and right side of the relationship based on the bRightSide flag.  However, with my test layer of lines and polygons which looks like

Image1.jpg

Relative to the highlighted street segment, my program finds that it touches polygons A, B, and C but the polygons that I will be interested in are going to be A and C since they are the ones on the left and right of the line segment. B is just touch -- or in the case of a segment that is truly perpendicular to B -- so I would expect the bRightSide flag to be incorrect for HitTest in this case.

Any suggestions or a better solution?

Thanks

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

I can think of two ways to do this.

Create two points on either side of the line at its midpoint using the IConstructPoint.ConstructOffset Method.

With each point do the hittest to determine which side of the line it is then find the underlying polygon with a search query.

The other method is to use topology. Programmatically create a topology graph around the line with the line and polygons. Get the topology edge the line belongs to then get the left and right polygons via the ITopologyEdge methods (LeftParents, RightParents).

If you have a bunch of these to do I don't know which approach will be quicker but you're probably more familiar with the code in the first option.

View solution in original post

2 Replies
by Anonymous User
Not applicable

I can think of two ways to do this.

Create two points on either side of the line at its midpoint using the IConstructPoint.ConstructOffset Method.

With each point do the hittest to determine which side of the line it is then find the underlying polygon with a search query.

The other method is to use topology. Programmatically create a topology graph around the line with the line and polygons. Get the topology edge the line belongs to then get the left and right polygons via the ITopologyEdge methods (LeftParents, RightParents).

If you have a bunch of these to do I don't know which approach will be quicker but you're probably more familiar with the code in the first option.

RiyasDeen
Occasional Contributor III

What you need is a spatial selection with SHARE_A_LINE_SEGMENT_WITH. If you are looking at doing this from C# then have a look at this discussion.

ISpatialFilter.SpatialRelDescription : share a line segment with

0 Kudos