zoukankan      html  css  js  c++  java
  • 图形合并

            /// <summary> /// 计算合并面积(去掉岛) /// </summary> /// <param name="pArrayPolygon">图形集合</param> /// <param name="isShowError"></param> /// <returns></returns> public static IPolygon UnionOrRemoveRingFromPolygon(ArrayList pArrayPolygon, bool isShowError) { IPolygon pPolygon_Each = null; IPolygon pPolygon_Result = null; IGeometryCollection pGeometryCollection = null; ISegmentCollection pSegmentCollection_Ring = null; object oMissing = Type.Missing; try { if (pArrayPolygon == null) return null; if (pArrayPolygon.Count == 0) return null; pGeometryCollection = new PolygonClass(); pPolygon_Result = pGeometryCollection as IPolygon; for (int i = 0; i < pArrayPolygon.Count; i++) { pPolygon_Each = pArrayPolygon[i] as IPolygon; IGeometryCollection pGeometryCollection_Temp = null; pGeometryCollection_Temp = pPolygon_Each as IGeometryCollection; for (int j = 0; j < pGeometryCollection_Temp.GeometryCount; j++) { pSegmentCollection_Ring = new RingClass(); pSegmentCollection_Ring.AddSegmentCollection(pGeometryCollection_Temp.get_Geometry(j) as ISegmentCollection); pGeometryCollection.AddGeometry(pSegmentCollection_Ring as IGeometry, ref oMissing, ref oMissing); } } pPolygon_Result.SimplifyPreserveFromTo(); return pPolygon_Result; } catch (Exception ex) { //if (isShowError) //    MessageBox.Show("合并(去岛)多边形发生错误,错误信息为:->\r\n" + ex.Message, //                    "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } }   ----------------------------------------------- ITopologicalOperator 接口实现了union和ConstructUnion两种合并要素的方法,union只能实现两种要素的合并,不能实现两种以上的要素合 并,ConstructUnion方法可以实现两种以上的要素合并。这两种合并方法合并后,原来的要素还存在。这与merge方法有所区别。举个例子。有 两个面,面A和面B,这两个面不一定要相邻。选中两个面后,如果用Union,则产生一个新的面要素,即为面A和面B的集合,而原来的面A和面B依然保 留。如果用Merge也产生一个新的要素,几何形体依然为面A和面B的集合,即面C,但它的属性只能从A和B中选择一个,也就是说属性合并。而且原来的面 A和面B也就不存在了。另外,无论是Union还是Merge在合并的时间,必须选择同一种几何类型,如面与面合并,线与线合并。 具体代码如下: public void UnionFeatures() { IMap pMap = MapControl.Map; IActiveView pActiveView = pMap as IActiveView; IGeometryCollection Geometrybag = new GeometryBagClass();//装geometry的袋子 IEnumFeature pEnumFeat = (IEnumFeature)pMap.FeatureSelection; IFeature pFeat = pEnumFeat.Next(); object oMissing = Type.Missing; while (pFeat != null) { IGeometry pGeometry = pFeat.Shape as IGeometry; Geometrybag.AddGeometry(pGeometry, ref oMissing, ref oMissing);//将geometry装进袋子 pFeat.Delete(); pFeat = pEnumFeat.Next(); } ITopologicalOperator unionedpolygon = new PolygonClass(); unionedpolygon.ConstructUnion(Geometrybag as IEnumGeometry);// IGeometry pGeo = unionedpolygon as IGeometry; CreateUnionFeature(pGeo); pActiveView.Refresh(); }
  • 相关阅读:
    Xcode 4.1~4.6 + iOS 5、iOS 6免证书(iDP)开发+真机调试+生成IPA全攻略
    Java程序员快速入门Go语言
    企业站常用的点击后弹出下拉菜单导航
    企业站常用漂亮横向导航菜单
    点击弹出弹性下拉菜单效果
    很酷的伸缩导航菜单效果,可自定义样式和菜单项。
    导航条点击按钮切换效果
    不错的二级导航菜单特效
    商城常用产品分类导航条
    css实现鼠标经过导航文字偏位效果
  • 原文地址:https://www.cnblogs.com/adodo1/p/4327984.html
Copyright © 2011-2022 走看看