当前位置:   article > 正文

ARCGIS PRO SDK VB2022 要素几何独立操作_arcgispro sdk getfeatureclass()

arcgispro sdk getfeatureclass()

一、获取要素的几何图形pGeometry

1、创建新要素:例如新建线要素line1 

  1. Dim pts As List(Of MapPoint) = New List(Of MapPoint)
  2. Dim pGeometry As ArcGIS.Core.Geometry.Geometry
  3. pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0))
  4. pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0))
  5. pts.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0))
  6. Dim line1 As ArcGIS.Core.Geometry.Polyline = PolylineBuilderEx.CreatePolyline(pts)
  7. pGeometry = line1

2、获取加载图层的要素,TK_LINE图层名称

  1. Dim pLayer1 As FeatureLayer = Map.FindLayers("TK_LINE").First()
  2. Dim pfeatureClass As FeatureClass
  3. Dim tableCursor As RowCursor
  4. Dim pGeometry As ArcGIS.Core.Geometry.Geometry
  5. Await QueuedTask.Run(Sub()
  6. pfeatureClass = pLayer1.GetFeatureClass
  7. tableCursor = pfeatureClass.Search()
  8. While tableCursor.MoveNext
  9. pfeature = CType(tableCursor.Current, Feature)
  10. pGeometry = pfeature.GetShape
  11. End While
  12. End Sub)

一、平移

  1. Dim pGeometry As ArcGIS.Core.Geometry.Geometry
  2. Dim pGeometry1 As ArcGIS.Core.Geometry.Geometry
  3. Dim dx As Double
  4. Dim dy As Double
  5. '将pGeometry按X、Y方向各自的偏移量,平移pGeometry,得到pGeometry1
  6. pGeometry1 = GeometryEngine.Instance.Move(pGeometry, dx, dy)

二、缩放

  1. Dim pGeometry As ArcGIS.Core.Geometry.Geometry
  2. Dim pGeometry1 As ArcGIS.Core.Geometry.Geometry
  3. Dim Lpoint As MapPoint
  4. Dim dx As Double
  5. Dim dy As Double
  6. Dim Scale_x As Double
  7. Dim Scale_y As Double
  8. Dim px As Double
  9. Dim py As Double
  10. Lpoint = MapPointBuilderEx.CreateMapPoint(px, py) 'origin 缩放点
  11. '将pGeometry以缩放点Lpoint为中心按X、Y方向各自缩放比例,得到pGeometry1
  12. pGeometry1 = GeometryEngine.Instance.Scale(pGeometry, Lpoint, Scale_x, Scale_y)

三、旋转

  1. Dim pGeometry As ArcGIS.Core.Geometry.Geometry
  2. Dim pGeometry1 As ArcGIS.Core.Geometry.Geometry
  3. Dim Lpoint As MapPoint
  4. Dim PRotate As Double '旋转角
  5. Dim px As Double
  6. Dim py As Double
  7. Lpoint = MapPointBuilderEx.CreateMapPoint(px, py) 'origin 缩放点
  8. '将pGeometry以旋转点Lpoint为中心,得到pGeometry1
  9. pGeometry1 = GeometryEngine.Instance.Scale(pGeometry, Lpoint, Scale_x, Scale_y)
  10. Geometry rotatedPolyline = GeometryEngine.Instance.Rotate(textLine, origin, System.Math.PI *PRotate/180)

四、复制平移

  1. Dim Layer As FeatureLayer = Map.FindLayers("TK_LINE").First()
  2. Dim dx As Double
  3. Dim dy As Double
  4. '创建编辑器
  5. Dim duplicateFeatures = New EditOperation
  6. duplicateFeatures.Name = "Duplicate Features"
  7. '创建【inspector】实例
  8. Await QueuedTask.Run(Sub()
  9. Dim insp2 = New Inspector
  10. '加载
  11. Dim Oid As Long = 2
  12. insp2.Load(Layer, Oid)
  13. pfeatureClass = Layer.GetFeatureClass
  14. '获取复制对象
  15. Dim geom As ArcGIS.Core.Geometry.Geometry = insp2("SHAPE")
  16. '复制要素及全属性复制
  17. Dim rtoken = duplicateFeatures.Create(insp2.MapMember, insp2.ToDictionary(Function(a) a.FieldName, Function(a) a.CurrentValue))
  18. If duplicateFeatures.IsEmpty = False Then
  19. If duplicateFeatures.Execute = True Then
  20. '移动位置
  21. Dim modifyOp = duplicateFeatures.CreateChainedOperation
  22. modifyOp.Modify(Layer, rtoken.ObjectID, GeometryEngine.Instance.Move(geom, dx, dy))
  23. If modifyOp.IsEmpty = False Then
  24. modifyOp.Execute()
  25. End If
  26. End If
  27. End If
  28. End Sub)

五、平行复制

  1. Dim roadsLayer = MapView.Active.Map.FindLayers("Roads").FirstOrDefault()
  2. ' 建立平行复制生成器,并设置参数
  3. Dim parOffsetBuilder = New ParallelOffset.Builder()
  4. With parOffsetBuilder
  5. .Selection = MapView.Active.Map.GetSelection() '所选要素
  6. '.Template = roadsLayer.GetTemplate("Freeway") '模板(可以不选)
  7. .Distance = 200 '偏移距离
  8. .Side = ParallelOffset.SideType.Both '偏移方式(左,右,两侧)
  9. .Corner = ParallelOffset.CornerType.Mitered '拐角处理方式(圆角,斜接角,斜面角)
  10. .Iterations = 1 '重复偏移的次数
  11. .AlignConnected = False '是否对齐连接线的方向
  12. .CopyToSeparateFeatures = False '是否复制到独立要素
  13. .RemoveSelfIntersectingLoops = True '是否移除自相交环
  14. End With
  15. '创建编辑器并执行
  16. Dim parallelOp = New EditOperation()
  17. parallelOp.Create(parOffsetBuilder)
  18. If parallelOp.IsEmpty = False Then
  19. Dim Result = parallelOp.Execute()
  20. If Result = False Then
  21. MsgBox("操作失败。")
  22. Exit Sub
  23. End If
  24. End If

六、炸开多部件

  1. Dim FeatureLayer = MapView.Active.Map.FindLayers("TK_Polygon").FirstOrDefault()
  2. Layer = FeatureLayer
  3. pfeatureClass = Layer.GetFeatureClass
  4. Dim POid As List(Of Long)
  5. POid = New List(Of Long)
  6. POid.Add(0)
  7. explodeFeatures.Explode(FeatureLayer, POid, True)
  8. If explodeFeatures.IsEmpty = False Then
  9. Dim result = explodeFeatures.Execute()
  10. If result = False Then
  11. MsgBox("操作失败。")
  12. Exit Sub
  13. End If
  14. End If

七、缓冲

Geometry1 = GeometryEngine.Instance.Buffer(Geometry, 5.0)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/878162
推荐阅读
相关标签
  

闽ICP备14008679号