Looking for line intersections at a vertex

678
3
Jump to solution
07-31-2014 01:32 PM
MarkParr
New Contributor

Doing some testing with a C# program using HitTest() and esriGeometryPartVertex trying to determine if the intersection of two or more lines is at each other From/To points with mixed results.

I have drawn some test layers where I purposefully draw the lines that have only a From and To vertex and they connect with other lines at one of their From/To vertices.  I then run a program against that layer using the following code snippet:

double dblRadius = 0.0;

double dblHitDist = 0.0;

int lPartIdx = -1;

int lSegIdx = -1;

bool blnRightSide = false;

IHitTest FeatureHitTest = IntFeature.Shape as IHitTest;

bool HitTestResult = FeatureHitTest.HitTest(VertexPt, dblRadius, esriGeometryHitPartType.esriGeometryPartVertex,

                                             null, ref dblHitDist, ref lPartIdx, ref lSegIdx, ref blnRightSide);

where VertexPt is a From or To point of the source line and IntFeature is an intersecting line feature

When running this, some segments/intersections show a TRUE HitTestResult while others show FALSE even though the lines are connected to endpoints when drawn.  There is no rhyme or reason to the TRUE/FALSE return.

I purposefully set by the "radius" to 0 thinking that will give me points that are right on top of one another and maybe that is problem.  When I select a decimal non zero number the HitTestResults start becoming TRUE.  How granular is that Radius?  Is it related to my Map Units or Display Units or something else?  Is that the root of my problem?

Thanks

0 Kudos
1 Solution

Accepted Solutions
RiyasDeen
Occasional Contributor III

That number should be equal to your feature class XY tolerance.

View solution in original post

0 Kudos
3 Replies
RiyasDeen
Occasional Contributor III

That number should be equal to your feature class XY tolerance.

0 Kudos
MarkParr
New Contributor

Is there a way to programmatically in C# to get the XY Tolerance?

0 Kudos
ModyBuchbinder
Esri Regular Contributor

Cast you spatial reference to ISpatialReferenceTolerance and you will have it.

I think it is the dataframe spatial reference.

0 Kudos