I have a simple spatial feature selection function that includes:
public static void SelectByLocation(IFeatureClass sourceFC, ILayer selectLayer) { Geoprocessor GP = new Geoprocessor(); SelectLayerByLocation selectLoc = new SelectLayerByLocation(); selectLoc.in_layer = selectLayer; selectLoc.select_features = sourceFC; RunTool(GP, selectLoc, null); ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } It works correctly passing an IFeatureClass and an ILayer, however I would like to pass a selected subset of records from the IFeatureClass (for example: only the record with the most recent date or count). I've tried changing it to accept an ILayer as the first parameter and applying a selection to that with no result. I've also tried passing an IFeature object of the intended feature dynamically cast as an IFeatureClass. This latter method returns every row in the select features layer. For reference, I'm calling it now like this:
List affectedFeatures = featureSelector(polyFC, layerList["SelectionLayer"], SelectList); Where featureSelector() calls the spatial select with "polyFC" as IFeatureClass, layerList["selectionLayer"] as a reference to the ILayer selection layer, and SelectList as a list referencing fields to return from the selection layer. So, I suppose what I'm asking is: is it possible to pass an IFeature to the first method and get a proper spatial selection returned? For what it's worth this is always polygons selecting polygons.
أكثر...
public static void SelectByLocation(IFeatureClass sourceFC, ILayer selectLayer) { Geoprocessor GP = new Geoprocessor(); SelectLayerByLocation selectLoc = new SelectLayerByLocation(); selectLoc.in_layer = selectLayer; selectLoc.select_features = sourceFC; RunTool(GP, selectLoc, null); ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } It works correctly passing an IFeatureClass and an ILayer, however I would like to pass a selected subset of records from the IFeatureClass (for example: only the record with the most recent date or count). I've tried changing it to accept an ILayer as the first parameter and applying a selection to that with no result. I've also tried passing an IFeature object of the intended feature dynamically cast as an IFeatureClass. This latter method returns every row in the select features layer. For reference, I'm calling it now like this:
List affectedFeatures = featureSelector(polyFC, layerList["SelectionLayer"], SelectList); Where featureSelector() calls the spatial select with "polyFC" as IFeatureClass, layerList["selectionLayer"] as a reference to the ILayer selection layer, and SelectList as a list referencing fields to return from the selection layer. So, I suppose what I'm asking is: is it possible to pass an IFeature to the first method and get a proper spatial selection returned? For what it's worth this is always polygons selecting polygons.
أكثر...