laptop and a wrench

漏洞

The annotation feature created by ArcGIS Pro SDK fails to rotate when MapView is rotated by a specified angle.

上次发布: March 30, 2020 ArcGIS Pro SDK for .NET
漏洞 ID 编号 BUG-000129683
已提交March 26, 2020
上次修改时间June 5, 2024
适用范围ArcGIS Pro SDK for .NET
找到的版本2.5
操作系统Windows OS
操作系统版本10.0 64 Bit
状态Will Not Be Addressed

附加信息

The code here is for creating a point annotation. Create a two-point annotation if staying horizontal with the map is not desired. A replacement C# file doing this is as below: using System; using System.Linq; using System.Threading.Tasks; using System.Collections.Generic; using ArcGIS.Core.CIM; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Editing; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using ArcGIS.Desktop.Editing.Attributes; namespace AGP_AnnoEdit { internal class AddAnnoTool : MapTool { private int _seq = 0; public AddAnnoTool() { IsSketchTool = true; UseSnapping = true; SketchOutputMode = ArcGIS.Desktop.Mapping.SketchOutputMode.Map; SketchType = SketchGeometryType.Point; } protected override Task OnToolActivateAsync(bool active) { return base.OnToolActivateAsync(active); } protected override async Task OnSketchCompleteAsync(Geometry geometry) { bool creationResult = false; await QueuedTask.Run(() => { var map = ArcGIS.Desktop.Mapping.MapView.Active.Map; AnnotationLayer annoLayer = map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); creationResult = StoreNewFeatureAnno(annoLayer, geometry, (++_seq).ToString()); }); return creationResult; } // patterned after https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Editing-Annotation internal static bool StoreNewFeatureAnno(AnnotationLayer annoLayer, ArcGIS.Core.Geometry.Geometry geometry, string textStr) { bool creationResult = false; string message = String.Empty; // Create an edit operation var createOperation = new EditOperation(); createOperation.Name = string.Format("Create {0}", annoLayer.Name); createOperation.SelectNewFeatures = false; // get the anno feature class var fc = annoLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass; // get the featureclass CIM definition which contains the labels, symbols var fcDefinition = fc.GetDefinition() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition; var labels = fcDefinition.GetLabelClassCollection(); var symbols = fcDefinition.GetSymbolCollection(); // make sure there are labels, symbols if ((labels.Count == 0) || (symbols.Count == 0)) return false; // use the first label class var label = labels[0]; // each label has a textSymbol // the symbolName *should* be the symbolID to be used var symbolName = label.TextSymbol.SymbolName; int symbolID = -1; if (!int.TryParse(symbolName, out symbolID)) { // int.TryParse fails - attempt to find the symbolName in the symbol collection foreach (var symbol in symbols) { if (symbol.Name == symbolName) { symbolID = symbol.ID; break; } } } // no symbol? if (symbolID == -1) return false; // load the schema Inspector insp = new Inspector(true); insp.LoadSchema(annoLayer); // ok to access AnnotationClassID this way - it is guaranteed to exist insp["AnnotationClassID"] = label.ID; insp["SymbolID"] = symbolID; CIMTextSymbol textSymbol = SymbolFactory.Instance.ConstructTextSymbol(CIMColor.CreateRGBColor(0, 0, 0), 12, "Arial", "normal"); double tolerance = geometry.SpatialReference?.XYTolerance ?? 0.001; // Create a two point line from the input point so that it remains in a fixed position when the map is rotated. Polyline polyline = Create2PointPolylineFromPoint(geometry as MapPoint, tolerance * 2.0, 0); // y=0 so horizontal // set up some properties AnnotationProperties annoProperties = insp.GetAnnotationProperties(); annoProperties.FontName = textSymbol.FontFamilyName; annoProperties.FontSize = textSymbol.GetSize(); annoProperties.TextString = textStr; annoProperties.VerticalAlignment = ArcGIS.Core.CIM.VerticalAlignment.Bottom; annoProperties.HorizontalAlignment = ArcGIS.Core.CIM.HorizontalAlignment.Center; annoProperties.Shape = polyline as Geometry; insp.SetAnnotationProperties(annoProperties); // Queue feature creation createOperation.Create(annoLayer, insp); try { // Execute the operation creationResult = createOperation.Execute(); if (!creationResult) message = createOperation.ErrorMessage; } catch (GeodatabaseException exObj) { message = exObj.Message; } if (!string.IsNullOrEmpty(message)) MessageBox.Show(message); return creationResult; } internal static Polyline Create2PointPolylineFromPoint(MapPoint point, double xtol, double ytol) { if (point == null) return null; // use the starting point and offsets to construct the points var point1 = GeometryEngine.Instance.Move(MapPointBuilder.CreateMapPoint(point), -xtol, -ytol) as MapPoint; var point2 = GeometryEngine.Instance.Move(MapPointBuilder.CreateMapPoint(point), xtol, ytol) as MapPoint; return PolylineBuilder.CreatePolyline(new List() { point1, point2 }); } } }

重现步骤

漏洞 ID: BUG-000129683

软件:

  • ArcGIS Pro SDK for .NET

当漏洞状态发生变化时获得通知

下载 Esri 支持应用程序

发现关于本主题的更多内容

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项