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 ;


 

你可能感兴趣的:(AO中如何判断polyline的类型)