Geometry 对象浅析
Points
一个点包括X、Y坐标,同时可以增加M、Z值及ID属性来扩展点的功能。
Multipoints
点的集合,多点组成Multipoint几何类型,使用multipoint对象实现了的IPointCollection接口可以访问所有的点元素,这些点同样可以拥有M、Z值及ID属性来获得更多的地理空间内涵。
下面列举一个例子,通过一个已知的polyline来定义一个新的multipart polyline。
ISegment接口的QueryNormal方法用来在弧段上的某一点生成该弧段的法线,指定其长度,这样就生成了新的segment,并且多个path添加到geometryCollection中,以IPolyline的形式返回。public IPolyline ConstructMultiPartPolyline(IPolyline inputPolyline)
...{
IGeometry outGeometry = new PolylineClass();
![]()
//Always associate new, top-level geometries with an appropriate spatial reference.
outGeometry.SpatialReference = inputPolyline.SpatialReference;
![]()
IGeometryCollection geometryCollection = outGeometry as IGeometryCollection;
![]()
ISegmentCollection segmentCollection = inputPolyline as ISegmentCollection;
![]()
//Iterate over existing polyline segments using a segment enumerator.
IEnumSegment segments = segmentCollection.EnumSegments;
![]()
ISegment currentSegment;
int partIndex = 0;;
int segmentIndex = 0;;
segments.Next(out currentSegment,ref partIndex, ref segmentIndex);
while(currentSegment != null)
...{
ILine normal = new LineClass();
![]()
//Geometry methods with _Query_ in their name expect to modify existing geometries.
//In this case, the QueryNormal method modifies an existing line
//segment (normal) to be the normal vector to
//currentSegment at the specified location along currentSegment.
currentSegment.QueryNormal(esriSegmentExtension.esriNoExtension, 0.5, true, currentSegment.Length / 3, normal);
![]()
//Since each normal vector is not connected to others, create a new path for each one.
ISegmentCollection newPath = new PathClass();
object missing = Type.Missing;
newPath.AddSegment(normal as ISegment, ref missing, ref missing);
//The spatial reference associated with geometryCollection will be assigned to all incoming paths and segments.
geometryCollection.AddGeometry(newPath as IGeometry, ref missing, ref missing);
![]()
segments.Next(out currentSegment,ref partIndex, ref segmentIndex);
}
//The geometryCollection now contains the new, multipart polyline.
return geometryCollection as IPolyline;
}
Polylines
Polylines是有序path组成的集合,可以拥有M、Z和ID属性值。Polyline对象的IPointCollection接口包含了所有节点的复制,IGeometryCollection接口可以获取polyline的paths,ISegmentCollection接口可以获取 polyline的segments。
Polyline结构图
Polygons
Polygon是一系列rings组成的集合,可以拥有M、Z和ID属性值。每一个ring由一个或多个segment组成,Polygon或ring对象的IPointCollection接口包含了所有节点的复制,IGeometryCollection接口可以获取polygon的rings, ISegmentCollection接口可以获取polygon的segments。
Polygon结构图
0