1 /// <summary> 2 /// 按内环(孔洞)面积删除内环 3 /// </summary> 4 /// <param name="pPolygon"></param> 5 /// <param name="Area">删除小于此值的内环,当值小于等于0时全部删除</param> 6 /// <returns></returns> 7 public IPolygon Delete_InteriorRingBag(IPolygon pPolygon,double Area) 8 { 9 IPolygon4 pPolygon4 = pPolygon as IPolygon4; 10 //外环 11 IGeometry pGeoExter = (pPolygon4.ExteriorRingBag as IGeometryCollection).get_Geometry(0); 12 13 14 15 //内环 16 IGeometryCollection pGeos = pPolygon4.get_InteriorRingBag(pGeoExter as IRing) as IGeometryCollection; 17 18 19 for (int i = 0; i < pGeos.GeometryCount; i++)//遍历内环,对满足要求的内环Union至输入polygon 20 { 21 IGeometry pGeoInter = pGeos.get_Geometry(i); 22 23 if (Math.Abs((pGeoInter as IArea).Area) > (Area<=0?double.MaxValue:Area)) 24 { 25 ITopologicalOperator pTopo = pPolygon as ITopologicalOperator; 26 IPointCollection pinterPoints = pGeoInter as IPointCollection; 27 28 IPointCollection pPointsNew = new PolygonClass(); 29 pPointsNew.AddPointCollection(pinterPoints); 30 IPolygon pU = pPointsNew as IPolygon; 31 32 ITopologicalOperator pTopoSim = pU as ITopologicalOperator; 33 pTopoSim.Simplify(); 34 35 pPolygon = pTopo.Union(pU) as IPolygon; 36 } 37 } 38 return pPolygon; 39 }