AO中如何判断polyline的类型

遇到这样一个问题,如何判断得到的polyline对象是否为圆弧,简单思考后直接判断polyline的gemetryType,但是这是错误的。
正确的方法是qi得到对应的ISegmentCollection接口,查询segmentCollection中每个segment的gemetryType,可以判断polyline的构造线型.
原因倒是很简单,复杂的polyline可以看成是多个segment的集合,但是当前我的每个polyline对象都是由一个segment构成,所以可以按如下方式写代码:
  ipPolylineFeatureClass->Search(NULL,VARIANT_FALSE,&ipFeatureCursor);

                ipFeatureCursor->NextFeature(&ipFeature);
              
    IGeometryPtr ipGeometry;
                IPolylinePtr ipPolyline;
    long  lOID;
    esriGeometryType   enuGeomType;
       ipFeature->get_Shape(&ipGeometry);
                ipFeature->get_OID(&lOID);
              
   // ipGeometry->get_GeometryType(&enuGeomType);
                IGeometryCollectionPtr ipGeometryCollection;
                hr=ipGeometry->QueryInterface(IID_IPolyline,(void**)&ipPolyline);
                if(FAILED(hr))
       return ;
              
    hr=ipPolyline->QueryInterface(IID_IGeometryCollection,(void**)&ipGeometryCollection);
                if(FAILED(hr))
       return ;
    long lGeometryCount;
       hr= ipGeometryCollection->get_GeometryCount(&lGeometryCount);
                if(FAILED(hr))
       return ;
               
                ISegmentCollectionPtr ipSegmentCollection;
                ipSegmentCollection=ipGeometry;
                long lSegmentCount;
                ipSegmentCollection->get_SegmentCount(&lSegmentCount);
                if(FAILED(hr))
       return ;
    ISegmentPtr ipSegment;
                ipSegmentCollection->get_Segment(0,&ipSegment);
                if(FAILED(hr))
       return ;
    esriGeometryType   enuSegmentGeomType;
               hr= ipSegment->get_GeometryType(&enuSegmentGeomType);
                if(FAILED(hr))
       return ;


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值