Geometry 集合接口

IGeometryCollection

IGeometryCollection 接口被 Polygon,Polyline, Multipoint, Multipatch, Trangle,Trangle Strip,Trangle Fan 和 GeometryBag 所实现。


Geometry 属性
通过一个索引值返回一个组成该几何对象的某个子对象。

GeometryCount 属性

返回组成该几何对象的子对象的数目。

AddGeometry 方法
向一个几何对象添加一个几何对象,将子对象添加到几何的指定索引值的位置。

AddGeometries 方法
向一个几何对象添加多个几何对象,将子对象数组添加到集合的最后。

在使用 AddGeometry 方法添加子对象到 Polygon 对象的过程中,如果子对象即 Ring 出现覆盖现象,那么多边形就没有封闭或出现了包含关系,那么这个 Polygon 就不是简单 Polygon,因此通过 IGometryCollection 来创建一个 Polygon 时,需要使用 ITopologicalOperator  的 Simplify 方法保证其有效性。

private IPolygon ConstructorPolygon(List<IRing> pRingList)
{
	try
	{
		IGeometryCollection pGCollection = new PolygonClass();
		object o = Type.Missing;

		for (int i = 0; i < pRingList.Count; i++)
		{
			// 通过IGeometryCollection接口的AddGeometry方法向Polygon对象中添加Ring子对象
			pGCollection.AddGeometry(pRingList[i], ref o, ref o);
		}

		// QI至ITopologicalOperator
		ITopologicalOperator pTopological = pGCollection as ITopologicalOperator;
		
		// 执行Simplify操作
		pTopological.Simplify();

		IPolygon pPolygon = pGCollection as IPolygon;
		//返回Polygon对象
		return pPolygon;
	}
	catch (Exception Err)
	{
		return null;
	}
}

private IPolygon MergePolygons(IPolygon FirstPolygon, IPolygon SecondPolygon)
{
	try
	{
		// 创建一个Polygon对象
		IGeometryCollection pGCollection1 = new PolygonClass();
		IGeometryCollection pGCollection2 = FirstPolygon as IGeometryCollection;
		IGeometryCollection pGCollection3 = SecondPolygon as IGeometryCollection;

		// 添加FirstPolygon
		pGCollection1.AddGeometryCollection(pGCollection2);
		// 添加SecondPolygon
		pGCollection1.AddGeometryCollection(pGCollection3);

		// QI至ITopologicalOperator
		ITopologicalOperator pTopological = pGCollection1 as ITopologicalOperator;
		// 执行Simplify操作
		pTopological.Simplify();

		//返回Polygon对象
		IPolygon pPolygon = pGCollection1 as IPolygon;
		return pPolygon;
	}
	catch (Exception Err)
	{
		return null;
	}
}

ISegmentCollection

ISegmentCollection 接口被 Path, Ring, Polyline 和 Polygon 四个类实现。


IPointCollection
ISegmentCollection 可以被多个几个对象类所实现,如 Multipoint, Path, Ring, Polyline, Polygon, Trangle,Trangle Strip,Trangle Fan, Multipatch.


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值