ARCGIS PRO SDK 访问Geometry对象

一、Geometry常用对象

 二、主要类

1、ReadOnlyPartCollection:Polyline 和 Polygon 使用的 ReadOnlySegmentCollection 部件的只读集合,属性成员:​

名字 描述
Count 获取 ICollection 中包含的元素数。
TIEM 获取位于指定索引处的元素。
SpatialReference 获取或设置用于此只读部件集合的 SpatialReference

               方法: GetEnumerator    返回循环访问集合的枚举器。

2、ReadOnlyPointCollection  返回Geometry所有点(拐点或顶点)的MapPoints 的只读集合,属性成员:

名字 描述
Count 获取 ICollection 中包含的元素数。
TIEM 获取位于指定索引处的元素。
SpatialReference 获取或设置用于此只读部件集合的 SpatialReference

 方法: 

名字 描述
Copy2DCoordinatesToList 重载。
Copy3DCoordinatesToList 重载。
CopyPointsToList 将此列表中的 MapPoint 复制到给定的 MapPoint 列表中。
GetEnumerator 返回循环访问集合的枚举器。

三、ReadOnlySegmentCollection :Segment 类的只读集合。,属性成员:

名字 描述
Count 获取 ICollection 中包含的元素数。
TIEM 获取位于指定索引处的元素。
SpatialReference 获取或设置用于此只读部件集合的 SpatialReference

       方法:GetEnumerator    返回循环访问集合的枚举器

四、GetEnumerator 方法:返回循环访问集合的枚举器

  例如:

1、枚举数据段以获得长度

 Dim polylineParts As ReadOnlyPartCollection = Polyline.Parts

 '枚举数据段以获得长度
 Dim Len As Double = 0
 Dim lsegments As IEnumerator(Of ReadOnlySegmentCollection) = polylineParts.GetEnumerator()
 While lsegments.MoveNext()
     Dim seg As ReadOnlySegmentCollection = lsegments.Current
     For Each s As Segment In seg
         Len += s.Length
         '类型执行一些特定的操作 
         Select Case s.SegmentType
             Case SegmentType.Line
                 MsgBox("SegmentType.SegmentType.Line")
             Case SegmentType.Bezier
                 MsgBox("SegmentType.SegmentType.Bezier")
             Case SegmentType.EllipticArc
                 MsgBox("SegmentType.SegmentType.EllipticArc")
         End Select
     Next
 End While

2、ReadOnlyPointCollection示例

​
Dim segments As IEnumerator(Of MapPoint)
Dim parts As ReadOnlySegmentCollection
Dim x As Double 
Dim y As Double 
segments = polygon1.Points.GetEnumerator
'获取图形所有顶点坐标
Dim ppts As ReadOnlyPointCollection = polygon1.Points
'坐标总数
Dim ppts_Count As long=ppts.Count
'坐标访问
For i = 0 To ppts_Count - 1
    x = ppts.item(i).X
    y = ppts.item(i).Y
Next 

Dim enumPts As IEnumerator(Of MapPoint) = polygon1.Points.GetEnumerator()

Dim coordinates As IReadOnlyList(Of Coordinate2D) = polygon1.Copy2DCoordinatesToList()
Dim coordinate2Ds As IList(Of Coordinate2D) = New List(Of Coordinate2D)(10)
Dim subsetCoordinates2D As ICollection(Of Coordinate2D) = coordinate2Ds

'获取PPTS点集中从ID1开始,取10个坐标点,ID1是从0开始
ppts.Copy2DCoordinatesToList(ID1, 10, subsetCoordinates2D)
'subsetCoordinates2D坐标访问
For i = 0 To subsetCoordinates2D.Count - 1
    pv_x(i) = subsetCoordinates2D(i).X
    pv_y(i) = subsetCoordinates2D(i).Y
Next

​

3、获取多边形外环坐标

'获取
ppv = poly.Points
Dim parts As ReadOnlyPartCollection = poly.Parts
dbx_zds = parts.First.Count()
dbx_zds = parts.First.Count()      '不包含闭合点
Dim coordinate2Ds As IList(Of Coordinate2D) = New List(Of Coordinate2D)
Dim subsetCoordinates2D As ICollection(Of Coordinate2D) = coordinate2Ds
ppv.Copy2DCoordinatesToList(0, dbx_zds + 1, subsetCoordinates2D)   '坐标起点序号,从0开始,共dbx_zds + 1点,含多边形闭合点
’获取的坐标在subsetCoordinates2DIList(Of Coordinate2D)

五、GeometryBag :是 Geometry 对象的异构集合,成员如下:

名字 描述
Dimension 获取几何图形的尺寸。 (继承自 ArcGIS.Core.Geometry.Geometry)
Extent 重写。 获取此实例的最小封闭信封。
Geometries 获取此 GeometryBag 中的几何图形列表。
GeometryType  重写。获取几何类型。始终返回 GeometryType.GeometryBag。
HasID 获取一个值,该值指示几何图形是否具有 ID。
(继承自 ArcGIS.Core.Geometry.Geometry)
HasM 获取一个值,该值指示几何图形是否具有 M。
(继承自 ArcGIS.Core.Geometry.Geometry)
HasZ 获取一个值,该值指示几何图形是否具有 Z。
(继承自 ArcGIS.Core.Geometry.Geometry)
IsEmpty 重写。 获取一个值,该值指示此实例是否为空。
IsKnownSimple 指示根据数据库中存储的几何类型,此几何图形是否已知拓扑一致。
 (继承自 ArcGIS.Core.Geometry.Geometry)
IsKnownSimpleOgc 指示根据开放地理空间联盟 (OGC) 验证规范,此几何是否已知在
拓扑上是一致的。 (继承自 ArcGIS.Core.Geometry.Geometry)
Length 获取此几何图形的长度 (继承自 ArcGIS.Core.Geometry.Geometry)
PartCount 获取此实例中的零件(几何图形)数。
PointCount 重写。 获取此实例的所有部件中所有点的计数。
SpatialReference 获取此实例的空间参考。(继承自 ArcGIS.Core.Geometry.Geometry)

方法:

名字 描述
Clone 克隆此几何实例。由于几何对象是不可变的,因此永远不会更改,
因此返回的克隆将是此对象,而不是 这个实例。
 (继承自 ArcGIS.Core.Geometry.Geometry)
IsEqual 重载。
ToEsriShape 重载。重写。
ToJson 将此几何实例序列化为 ArcGIS JSON 几何制图表达。
 (继承自 ArcGIS.Core.Geometry.Geometry)
ToXml 将此几何实例序列化为 ArcGIS XML 几何制图表达。
(继承自 ArcGIS.Core.Geometry.Geometry)
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>