[GIS] Using ESRI.ArcGIS.DataManagementTools.RepairGeometry

arcgis-10.0arcobjects

I am trying to update some code from VB6 to VB.Net 2008 and have been generally successful. However, I came across an issue where, as it processes each polygon in the shapefile, it implements the following code.

Dim lngExtRing as Integer
lngExtRing = pPolygon.ExteriorRingCount - 1
ReDim pExtRings(pPolygon.ExteriorRingCount - 1)
pPolygon.QueryExteriorRingsEx(pPolygon.ExteriorRingCount, pExtRings(0))
pExtRings(lngExtRing)

Once that code runs and you hover over the pExtRings portion of pExtRings(lngExtRing) for some polygons (not all), the first popup lists a ComObject but if you expand the plus, it indicates "Nothing".

I have run this on a shapefile that has 5 polygons and the two polygons that it fails on have negative areas. There are two ways that might resolve this, but I don't know how to implement either. One was to reverse the orientation if the area was negative, but I tried that on a different shapefile and it still failed on a polygon that did not have a negative area. The other, perhaps better, approach would be to implement the RepairGeometry class of ESRI.ArcGIS.DataManagementTools, but I have no clue on how to make it happen.

If anyone has any insight or examples of how to use RepairGeometry, I would certainly appreciate being enlightened.

Thanks

Dale

Best Answer


There are two things I can suggest:

  1. Are you using IPolygon interface or IPolygon4? Because in ESRI documentation it says IPolygon.ExteriorRingCount() does not work in .Net, use IPolygon4 instead
  2. Do you have slightest idea about the direction of digitization of these problem polygons? Again, as per ESRI, inner rings are characterized by a counterclockwise orientation

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/InteriorRingCount_Property/002m000002nt000000/
Cheers!