ArcEngine判断要素(feature)是否为multipart feature及分解(炸开)代码

来源:互联网 发布:c语言 外部接口 编辑:程序博客网 时间:2024/04/29 07:37
#region 校验合法性            ArrayList pFeatureArray = null;            pFeatureArray = Application.Editor.FeatureSelection();            int count=pFeatureArray.Count;            if (count<1)            {                MessageBox.Show("最少必须选择1个要素才能进行要素分解!", "提示");                return;            }#endregion   try            {                //启动编辑操作                Application.Editor.StartOperation();                #region 对选中的要素进行多部件测试及分解                int multipartcount = 0;                for (int i = 0; i < count; i++)                {                    IFeature pFeature = pFeatureArray as IFeature;                    if (pFeature.ShapeCopy.IsEmpty) continue;                    IGeometry pGeometry = pFeature.ShapeCopy;                    IGeometryCollection pGeocoll = pGeometry as IGeometryCollection;                    int geomcount = pGeocoll.GeometryCount;                    if (geomcount > 1)                    {                        multipartcount++;                        for (int k = 1; k < geomcount; k++)                        {                            IFeature newFeaturte = (pFeature.Class as IFeatureClass).CreateFeature();                            IFeatureEdit pFeatureEdit = pFeature as IFeatureEdit;                            pFeatureEdit.SplitAttributes(newFeaturte);                            IGeometry newGeom = pGeocoll.get_Geometry(k);                            if (pFeature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPolygon)                                newGeom=GeometryHelper.ConstructPolygon(newGeom);                            else                                newGeom = GeometryHelper.ConstructPolyline(newGeom);                            newGeom.SpatialReference = pFeature.ShapeCopy.SpatialReference;                            newFeaturte.Shape = newGeom;                            newFeaturte.Store();                        }                        IGeometry newGeom2 = pGeocoll.get_Geometry(0);                        if (pFeature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPolygon)                            newGeom2 = GeometryHelper.ConstructPolygon(newGeom2);                        else                            newGeom2 = GeometryHelper.ConstructPolyline(newGeom2);                        newGeom2.SpatialReference = pFeature.ShapeCopy.SpatialReference;                        pFeature.Shape = newGeom2;                        pFeature.Store();                        Application.Editor.StopOperation("分解多部件要素");                    }                    else                    {                        continue;                    }                }                if (multipartcount == 0)                {                    MessageBox.Show("未选择多部件要素!", "分解要素");                    return;                }                                                #endregion            }            catch (Exception ex)            {                Application.Editor.AbortOperation();                MessageHelper.WriteLog("分解多部件要素", ex);            }            finally            {                Application.ActiveView.Refresh();                FlashFeatures();            }

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 丰声用户不存在怎么办 微信用户不存在怎么办 社保卡忘记密码怎么办 斗鱼忘记邮箱怎么办 手机看斗鱼怎么办办卡 微博昵称受限怎么办 被新浪屏蔽了怎么办 微博qq忘记密码怎么办 三星盖乐世忘记密码怎么办 三盖乐世4忘记密码怎么办 密码锁钥匙丢了怎么办 商标是tm标怎么办 环保合格证掉了怎么办 车子合格证丢了怎么办 大牙附近肿了怎么办 办好营业执照后怎么办商标 商标十年到期了怎么办 公司注册了商标怎么办 2018年属兔不适合结婚怎么办 交通事故对方没钱赔怎么办 滴滴快车出车祸怎么办 交警法院扣车怎么办 肇事逃逸没钱赔怎么办 撞死人无力赔偿怎么办 宝贝咳嗽很厉害怎么办 开车有人别车怎么办 判刑罚金交不起怎么办 罚金太多交不起怎么办 判决书上的罚金怎么办 刑事罚款不交怎么办 缎面的鞋脏了怎么办 夏天脸上长粉刺怎么办 鬃狮不吃东西怎么办 买二手车的车牌怎么办 榴莲打开了肉没熟怎么办 gmat的prep做完怎么办 电脑没ip地址怎么办 电脑ip地址缺失怎么办 cos还原不了人物怎么办 执行局抓人十五天不放人怎么办 笔记本电脑键盘按键错乱怎么办