• ArcGIS Pro二次开发-识别工具


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using ArcGIS.Core.CIM;
    using ArcGIS.Core.Data;
    using ArcGIS.Core.Geometry;
    using ArcGIS.Desktop.Catalog;
    using ArcGIS.Desktop.Core;
    using ArcGIS.Desktop.Editing;
    using ArcGIS.Desktop.Extensions;
    using ArcGIS.Desktop.Framework;
    using ArcGIS.Desktop.Framework.Contracts;
    using ArcGIS.Desktop.Framework.Dialogs;
    using ArcGIS.Desktop.Framework.Threading.Tasks;
    using ArcGIS.Desktop.Mapping;
    
    
    
    using System.Windows.Input;
    
    
    
    
    
    namespace ProAppModule1
    {
        internal class MapToolSelect : MapTool
        {
            public MapToolSelect()
    
            {
    
                IsSketchTool = true;
    
                SketchType = SketchGeometryType.Circle;
    
                SketchOutputMode = SketchOutputMode.Screen;
    
            }
    
    
    
            protected override Task OnToolActivateAsync(bool active)
    
            {
    
                return base.OnToolActivateAsync(active);
    
            }
    
    
    
            protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
    
            {
                var mv = MapView.Active;
    
                var identifyResult = await QueuedTask.Run(() =>
    
                {
    
                    var sb = new StringBuilder();
    
    
    
                    // Get the features that intersect the sketch geometry. 
    
                    var features = mv.GetFeatures(geometry);
    
    
    
                    // Get all layer definitions
    
                    var lyrs = mv.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
    
                    foreach (var lyr in lyrs)
    
                    {
    
                        var fCnt = features.ContainsKey(lyr) ? features[lyr].Count : 0;
    
                        sb.AppendLine($@"{fCnt} {(fCnt == 1 ? "record" : "records")} for {lyr.Name}");
    
                    }
    
                    return sb.ToString();
    
                });
    
                MessageBox.Show(identifyResult);
    
                return true;
    
            }
    
        }
    
    
    }
  • 相关阅读:
    Lumen源码分析之 一步一步带你实现Lumen容器(一)
    php 注册器模式 工厂模式
    理解 PHP 依赖注入 和 控制反转
    composer使用git作为仓储
    monolog记录日志
    Jupyter Notebook快捷键
    图像灰度化
    一道算法题:拼数字
    [转]Vue生态系统中的库
    window.postMessage实现网页间通信
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12462762.html
Copyright © 2020-2023  润新知