I have two Point Feature Classes - Say FC1 and FC2 - added in the current map
I want to Select Features from FC1 that intersect with Features of FC2
This can be easily done with ArcMap's Select By Location (Providing FC1 in target layer, and FC2 in source layer)
However, when I'm trying to do it in ArcObjects, using IFeatureClass.Search Method and following this example I have the following code
public ESRI.ArcGIS.Geodatabase.IFeatureCursor PerformSpatialQuery(ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass, ESRI.ArcGIS.Geometry.IGeometry searchGeometry, ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum spatialRelation, System.String whereClause)
{
// create a spatial query filter
ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilter=new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();
// specify the geometry to query with
spatialFilter.Geometry=searchGeometry;
// specify what the geometry field is called on the Feature Class that we will be querying against
System.String nameOfShapeField=featureClass.ShapeFieldName;
spatialFilter.GeometryField=nameOfShapeField;
// specify the type of spatial operation to use
spatialFilter.SpatialRel=spatialRelation;
// create the where statement
spatialFilter.WhereClause=whereClause;
// perform the query and use a cursor to hold the results
ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter=new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
queryFilter=(ESRI.ArcGIS.Geodatabase.IQueryFilter)spatialFilter;
ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor=featureClass.Search(queryFilter, false);
return featureCursor;
}
In this function, I have to provide a feature class and a IGeometry as parameters, rather than two Feature Classes similar to Select By Location
Is there any other method, that simply takes two Feature Classes as whole and return the intersecting geometry from one Feature class? Or do I have to Iterate through the complete Feature Class and provide each point's geometry one by one?