Select to view content in your preferred language

Get First Feature from Point Search in GeoFeatureLayer.snippet

748
2
06-18-2010 03:25 AM
ThomasWaenke
Deactivated User
Hi All,

I need a function that returns a feature that is selected by a mouse click. The "Get First Feature from Point Search in GeoFeatureLayer" Snippet (C#) that is supplied with ArcGIS returns a feature when the envelope of the search point intersects the envelope of the target. The problem is that a long line feature can have a large envelope that is always intersected. As a result I always get this line even when the mouse click is far away.

Is there a way to get only the feature that "really" intersects i.e. the line that I clicked on.

Thomas Waenke
0 Kudos
2 Replies
AlexanderGray
Honored Contributor
The key is the type of search being done.  That is defined by the spatial relationship in the spatial filter.
Replace this line
spatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects
with
spatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects
0 Kudos
ThomasWaenke
Deactivated User
Thanks,

it works.
0 Kudos