markparr

Finding line intersections

Discussion created by markparr on Jan 23, 2012
Starting with a street line segment from a centerline shapefile, I am trying to determine the intersection points of the intersecting lines from the same layer and determine if these points are vertex points of the original line and intersecting line.  I am using ITopologicalOperator.Intersect() and IHitTest.HitTest() methods with varying results. 

First off, I do a query using a SpatialFilter of esriSpatialRelEnum.esriSpatialRelIntersects to find all the intersecting lines for the line in question.  I then loop thru these resulting lines to determine the intersection point of a line with the original using the ITopologicalOperator.Intersect() method with an ???esri.GeometryDimension.esriGeometry0Dimension???.  With that resulting point, I then use the IHitTest.HitTest() method with ???esriGeometryHitPartType.esriGeometryPartVertex??? against both line segments to determine if the ITopologicalOperator.Intersect result is a vertex of either line.

The results that I am seeing is mixed:  With a line that I am testing, the first result of the query intersects but not at a vertex point for either line.  The resulting HitTest() calls are false for both lines.  For the second line from the query, it intersects the original line at a vertex point for both lines and HitTest() returns true for both lines.  For the third line from the query, both lines also intersect at a vertex point for both lines but the HitTest() returns false for both lines.

I added logic to spin the vertex points of both lines and display their corresponding (X, Y) values of the vertex points.  I am also displaying the (X, Y) for the ITopologicalOperator.Intersect() result.  In looking at the vertex (X, Y)s of the two lines, the displayed values for the common vertex points are all the same.  For the intersection point (X, Y)s of the lines that return true, those values also match.  For the line(s) that return false even though there should be a Hit, the X values are the same but the Y values are just a little off well into the decimal portion of the value (e.g. 123.4567098 instead of 123.4567890).

What am I doing wrong?  Is this the right way to do this or should I be doing something?

Any help/direction would be appreciated.  Thanks.

Outcomes