How to determine the polyline type in AO

Source: Internet
Author: User

If you encounter such a problem, how can you determine whether the Polyline Object is an arc? After a simple thought, you can directly determine the gemetrytype of polyline, but this is wrong.
The correct method is to obtain the corresponding isegmentcollection interface from QI. query the gemetrytype of each segment in segmentcollection to determine the construction line of the polyline.
The reason is very simple. The complex polyline can be considered as a set of multiple segments. However, each of my polyline objects is composed of a segment, so you can write code as follows:
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;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.