ArcGIS Pro创建点要素
// Copyright 2019 Esri // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. using System.Threading.Tasks; using ArcGIS.Desktop.Editing; using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Geometry; namespace AnnoTools { /// <summary> /// An annotation construction tool that uses a point sketch type. /// </summary> /// <remarks> /// Annotation construction tools work as per other construction tools. Set the categoryRefID in the daml file to be "esri_editing_construction_annotation". /// <para></para> /// Annotation feature classes store polygon geometry. This polygon is the bounding box of the text of an annotation feature. The bounding box /// is calculated from the text string, font, font size, angle orientation and other text formatting attributes of the feature. It is automatically /// updated by the application each time the annotation attributes are modified. You should never need to access or modify an annotation features /// polygon shape. /// <para></para> /// The text attributes of an annotation feature are represented by a CIMTextGraphic. The CIMTextGraphic consists of the text string, text attributes /// (such as verticalAlignment, horizontalAlignment, fontFamily, fontSize etc), callouts, leader lines and the CIMTextGraphic geometry. This geometry /// can be a point, straight line, bezier curve, multipoint geometry or GeometryBag and represents the baseline geometry that the text string sits upon. /// <para></para> /// When creating an annotation feature the geometry passed to the Create method is the CIMTextGraphic geometry. /// </remarks> internal class AnnoSimpleConstructionTool : MapTool { public AnnoSimpleConstructionTool() { IsSketchTool = true; UseSnapping = true; // set the sketch type to point SketchType = SketchGeometryType.Point; } /// <summary> /// Called when the sketch finishes. This is where we will create the edit operation and then execute it. /// </summary> /// <param name="geometry">The geometry created by the sketch.</param> /// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns> protected override Task<bool> OnSketchCompleteAsync(Geometry geometry) { if (CurrentTemplate == null || geometry == null) return Task.FromResult(false); // Create an edit operation var createOperation = new EditOperation(); createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name); createOperation.SelectNewFeatures = true; // pass the point geometry to the Create method createOperation.Create(CurrentTemplate, geometry); // Execute the operation return createOperation.ExecuteAsync(); } } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2019-03-24 ArcGIS中国工具,版权声明,本人没有授权任何单位和个人销售,其他都是盗版,为了你个人和单位利益,请勿购买。 销售QQ:27652980,853740877,电话:18987281928,13108507190,qq群310964401