public bool HasAssociatedFeatureService {get;}
Public ReadOnly Property HasAssociatedFeatureService As Boolean
public bool HasAssociatedFeatureService {get;}
Public ReadOnly Property HasAssociatedFeatureService As Boolean
var featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType<FeatureSceneLayer>().FirstOrDefault(); if (!featSceneLayer.HasAssociatedFeatureService || !featSceneLayer.IsEditable) return;//not supported //TODO continue editing here...
//must support editing! //var featSceneLayer = ... ; if (!featSceneLayer.HasAssociatedFeatureService || !featSceneLayer.IsEditable) return; //Check geometry type...must be point in this example if (featSceneLayer.ShapeType != esriGeometryType.esriGeometryPoint) return; var editOp = new EditOperation() { Name = "Create new 3d point feature", SelectNewFeatures = true }; var attributes = new Dictionary<string, object>(); //mapPoint contains the new 3d point location attributes.Add("SHAPE", mapPoint); attributes.Add("TreeID", "1"); editOp.Create(featSceneLayer, attributes); editOp.ExecuteAsync();//fyi, no await
//must support editing! //var featSceneLayer = .... ; if (!featSceneLayer.HasAssociatedFeatureService || !featSceneLayer.IsEditable) return; var delOp = new EditOperation() { Name = "Delete selected features" }; //Assuming we have a selection on the layer... delOp.Delete(featSceneLayer, featSceneLayer.GetSelection().GetObjectIDs()); await delOp.ExecuteAsync();//await if needed but not required
//must support editing! var featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType<FeatureSceneLayer>().FirstOrDefault(); if (!featSceneLayer.HasAssociatedFeatureService || !featSceneLayer.IsEditable) return; var ok = await QueuedTask.Run(() => { var editOp = new EditOperation() { Name = "Edit FeatureSceneLayer Attributes", SelectModifiedFeatures = true }; //make an inspector var inspector = new Inspector(); //get the attributes for the specified oid inspector.Load(featSceneLayer, oid); inspector["PermitNotes"] = "test";//modify editOp.Modify(inspector); return editOp.Execute();//synchronous flavor });
//var featSceneLayer = ....; if (featSceneLayer.HasAssociatedFeatureService) { //Must be called on the MCT using (var fc = featSceneLayer.GetFeatureClass()) { //TODO query underlying feature class } }
//assume the geometry used in SelectFeaturesEx() is coming from a //map tool... // //SketchType = SketchGeometryType.Rectangle; //SketchOutputMode = SketchOutputMode.Screen; await QueuedTask.Run(() => { var result = MapView.Active.SelectFeaturesEx(geometry); //Get scene layers with selections //At 2.x - var scene_layers = result.Where(kvp => kvp.Key is FeatureSceneLayer); var scene_layers = result.ToDictionary<FeatureSceneLayer>(); foreach (var kvp in scene_layers) { var scene_layer = kvp.Key as FeatureSceneLayer; var sel_oids = kvp.Value; //If there are attributes then get them if (scene_layer.HasAssociatedFeatureService) { var insp = new Inspector(); foreach (var oid in sel_oids) { insp.Load(scene_layer, oid); //TODO something with retrieved attributes } } } });
var featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType<FeatureSceneLayer>().First(); if (featSceneLayer.HasAssociatedFeatureService) { //Can Select and Search...possibly edit }
//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 = ...; if (featSceneLayer.HasAssociatedFeatureService) return;//Search and Select not supported await QueuedTask.Run(() => { QueryFilter qf = new QueryFilter() { ObjectIDs = new List<long>() { 6069, 6070, 6071 }, SubFields = "*" }; featSceneLayer.Select(qf, SelectionCombinationMethod.New); featSceneLayer.HideSelectedFeatures(); var selectionCount = featSceneLayer.SelectionCount; featSceneLayer.ShowHiddenFeatures(); selectionCount = featSceneLayer.SelectionCount; });
//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