public RowCursor Search( QueryFilter queryFilter )
Public Function Search( _ Optional ByVal queryFilter As QueryFilter _ ) As RowCursor
Parameters
- queryFilter
- A query filter or spatial filter
public RowCursor Search( QueryFilter queryFilter )
Public Function Search( _ Optional ByVal queryFilter As QueryFilter _ ) As RowCursor
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
System.InvalidOperationException | No associated feature service |
ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
//var featSceneLayer = ...; if (!featSceneLayer.HasAssociatedFeatureService) return;//Search and Select not supported //Multipatch (Object3D) or point? //var is3dObject = ((ISceneLayerInfo)featSceneLayer).SceneServiceLayerType // == esriSceneServiceLayerType.Object3D; var is3dObject = featSceneLayer.FeatureSceneLayerType == FeatureSceneLayerType.Object3D; await QueuedTask.Run(() => { var queryFilter = new QueryFilter { WhereClause = "Name = 'Ponderosa Pine'", SubFields = "*" }; int rowCount = 0; //or select... var select = featSceneLayer.Select(queryFilter) using (RowCursor rowCursor = featSceneLayer.Search(queryFilter)) { while (rowCursor.MoveNext()) { using (var feature = rowCursor.Current as Feature) { var oid = feature.GetObjectID(); var shape = feature.GetShape(); var attrib = feature["Name"]; if (is3dObject) { //shape is a multipatch } else { //shape is a point } rowCount += 1; } } } });
//var featSceneLayer = ...; //var sname = featSceneLayer.Name; await QueuedTask.Run(() => { if (!featSceneLayer.HasAssociatedFeatureService) return;//no search or select //Select all features within the current map view var sz = MapView.Active.GetViewSize(); var map_pt1 = MapView.Active.ClientToMap(new System.Windows.Point(0, sz.Height)); var map_pt2 = MapView.Active.ClientToMap(new System.Windows.Point(sz.Width, 0)); //Convert to an envelope var temp_env = EnvelopeBuilderEx.CreateEnvelope(map_pt1, map_pt2, MapView.Active.Map.SpatialReference); //Project if needed to the layer spatial ref SpatialReference sr = null; using (var fc = featSceneLayer.GetFeatureClass()) using (var fdef = fc.GetDefinition()) sr = fdef.GetSpatialReference(); var env = GeometryEngine.Instance.Project(temp_env, sr) as Envelope; //Set up a query filter var sf = new SpatialQueryFilter() { FilterGeometry = env, SpatialRelationship = SpatialRelationship.Intersects, SubFields = "*" }; //Select against the feature service var select = featSceneLayer.Select(sf); if (select.GetCount() > 0) { //enumerate over the selected features using (var rc = select.Search()) { while (rc.MoveNext()) { using (var feature = rc.Current as Feature) { var oid = feature.GetObjectID(); //etc. } } } } MapView.Active.Map.ClearSelection(); });
Target Platforms: Windows 11, Windows 10