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(); }
  • 相关阅读:
    动态规划解按摩师的最长预约时间
    C#中WinForm的Tab键顺序调整顺序
    内网穿透工具对比FRP+NPS+Zerotier与NAT服务器测试
    " " 和 ' ' 混用拼接html字符串,且含有事件,事件中有参数
    HAProxy在Windows下实现负载均衡与反向代理
    react 导入src外部的文件 Relative imports outside of src/ are not supported.
    11_实例
    C#删除指定目录下文件(保留指定几天前的日志文件)
    【转】系统创建定时执行任务bat批处理删除指定N天前文件夹的文件
    mariadb导如数据异常------Error Code: 1153
  • 原文地址:https://www.cnblogs.com/adodo1/p/4327262.html
Copyright © 2011-2022 走看看