// 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();
}
}
}
ArcGIS Pro创建点要素
原创
©著作权归作者所有:来自51CTO博客作者gisoracleplus的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
WPS二次开发系列:WPS SDK功能效果展示
WPS二次开发,WPS SDk功能效果展示
Word WPS 二次开发 Office -
ArcGIS Pro二次开发-创建图层
ArcGIS Pro二次开发-创建图层
ArcGIS Pro二次开发-创建图层 -
arcgis pro二次开发官方文档
ArcGIS Pro二次开发
arcgis pro -
ArcGIS Pro二次开发-空间查询
ArcGIS Pro二次开发-空间查询
ArcGIS Pro二次开发-空间查 -
ArcGIS Pro二次开发-添加字段
ArcGIS Pro二次开发-添加字段
ArcGIS Pro二次开发-添加字段 -
ArcGIS Pro二次开发-选择gdb
ArcGIS Pro二次开发-选择gdbask
ArcGIS Pro二次开发