ArcEngine开发:浅谈IPointCollection

IPointCollection接口非常灵活,在ArcEngine开发中经常要用到。下面来介绍下它的特性。

IPointCollection初始化,可以通过MultipointClass、PolylineClass、PolygonClass对象定义。

IPointCollection pPointCollection1 = new MultipointClass();
IPointCollection pPointCollection2 = new PolylineClass();
IPointCollection pPointCollection3 = new PolygonClass();

且通过as 与IMultipoint、Ipolyline、Ipolygon互相转换。

IMultipoint pMuPoint = pPointCollection1 as IMultipoint;
IPolyline  pPolyline = pPointCollection2 as IPolyline  ;
IPolygon    pPolygon = pPointCollection3 as IPolygon   ;

进而转成IGeometry类型,进而作为对应的几何类型添加到图层中的要素中。

IGeometry pGeometryPolyline = pPolyline as IGeometry;  //仅举一个例子
ITopologicalOperator pTop = pGeometryPolyline as ITopologicalOperator;
pTop.Simplify();
IFeature pFeature = fc.CreateFeature();  //fc为 IFeatureClass对象
pFeature.Shape = pGeometryPolyline;

其里面存储的是各个顶点的坐标(IPoint类型),可通过Point[]当做数组来调用。

 List<IPoint> pList = new List<IPoint>();
 for (int t = 0; t < pc.PointCount; t++)
 {
      pList.Add(pc.Point[t]);
      //pList.Insert(0,pc.Point[t]);
 }

当你以为它就是数组时,其实它还能这样访问pc.Point[-1]。pc.Point[-1]与pc.Point[PointCount-1]调用的是同一个点。然后依次类推。但是它无法访问pc.Point[PointCount],提示超出范围。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值