How to get the exterior ring from newly polygon?

839
3
04-08-2011 06:06 AM
keyuzhu
New Contributor
I used follow code to create a polygon:
    IPolygonPtr poly;
    poly.CreateInstance(CLSID_Polygon);
    IGeometryCollectionPtr pGeos;
    poly->QueryInterface(&pGeos);
    for( int i = 0;.....
    {
          IRingPtr ring;
 ring.CreateInstance(CLSID_Ring);
 IPointCollectionPtr ps;
 ring->QueryInterface(&ps);
 for (long j = 0;..........
 {
  IPointPtr pnt;
  pnt.CreateInstance(CLSID_Point);
  pnt->PutCoords(p.x, p.y);
  ps->AddPoint(pnt);
 }
 HRESULT hr = pGeos->AddGeometry(ring, NULL, NULL);
     }


After create it , I want to get the Exterior ring to check its direction. I use get_ExteriorRingBag method, And I got nothing? Why the exterior rings is NULL?
0 Kudos
3 Replies
keyuzhu
New Contributor
or how to repair geometry?
0 Kudos
ModyBuchbinder
Esri Regular Contributor
Try using ITopologicalOperator.Simplify , this will create a polygon from the collection of rings..

Have Fun
Mody
0 Kudos
keyuzhu
New Contributor
It works.Thank you, Mody.
0 Kudos