I'm working with ArcObjects, C# and ArcMap. I have an attribute table that has several rows of data including a "shape" field that holds a point geometry. I also have a random point. How can I iterate through each point in the table to see if it matches my random point?
I thought using something like ISpatialFilter would work, but I'm not sure if I'm using it right. My code is below:
IPoint _point = new PointClass();
_point.PutCoords(3605857.580, 516199.563);
ISpatialFilter _filter = new SpatialFilterClass();
_filter.Geometry = _point;
_filter.GeometryField = _featureClass.ShapeFieldName;
_filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
//_filter.WhereClause = "Shape = "+ _point+""; // DONT KNOW WHAT TO PUT
//_filter.SubFields = "Shape";
IFeatureCursor _featureCursor = _featureClass.Search(_filter, false);
while ((_featureCursor.NextFeature()) != null)
{
if (_point == _featureCursor)
{
MessageBox.Show("FOUND");
}
}
As you can see, I do have some code edited out as I'm not sure what to put in certain areas.
esriSpatialRelIntersects
. Often people choose to create a search envelope centered on the search point with a width and height based on a search tolerance. Otherwise your point will have to exactly intersect a point in the featureclass.