Exemplo n.º 1
0
        /// <summary>
        /// 代码图层标准化检查
        /// </summary>
        private void CheckLayer(object para)
        {
            Plugin.Application.IAppFormRef pAppForm  = para as Plugin.Application.IAppFormRef;
            System.Data.DataTable          Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示
            Datatable.Columns.Add("错误图层及相关要素", typeof(string));                     //创建一列
            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();

            ClearGrid.Operate(pAppForm, _AppHk);

            int count = _AppHk.MapControl.Map.LayerCount;//得以MAP上图层的总数

            if (count == 0)
            {
                return;            //图层为0,返回
            }
            SetCheckState.CheckShowTips(pAppForm, "代码图层标准检查开始.....");
            for (int n = 0; n < count; n++)
            {
                //遍历整个MAP上的图层
                ILayer temp_layer = _AppHk.MapControl.get_Layer(n);

                #region //判别是不是组,如果是,就从组中取一个层
                if (temp_layer is IGroupLayer)
                {
                    ICompositeLayer grouplayer = temp_layer as ICompositeLayer; //把组图层转成组合图层
                    int             G_count    = grouplayer.Count;              //组合图层的层数
                    if (G_count == 0)
                    {
                        return;
                    }
                    string Value_temp = G_count.ToString();

                    #region 初始化树
                    ArrayList LayerList = new ArrayList();//用来初始化树图的动态数组
                    //将所有不为空的要素类放入数组中
                    for (int L = 0; L < G_count; L++)
                    {
                        ILayer        layer   = grouplayer.get_Layer(L); ////定义用来接收指定组下面的图层
                        IFeatureLayer F_layer = layer as IFeatureLayer;  //转成要素层
                        if (F_layer == null)
                        {
                            continue;                                 //如果图层为空则返回
                        }
                        IFeatureClass F_class = F_layer.FeatureClass; //得到相应的要素类
                        if (F_class == null)
                        {
                            continue;
                        }
                        LayerList.Add(F_class);                   //将要素类放入动态数组
                    }
                    SetCheckState.TreeIni_Fun(LayerList, _AppHk); //初始化树
                    #endregion

                    for (int G = 0; G < LayerList.Count; G++)
                    {
                        ArrayList     FeatureList = new ArrayList();               //存放每个要素类下面的所有要素
                        int           g           = G + 1;                         //由于层的索引是从0开始的,所以得加1
                        IFeatureClass F_class     = LayerList[G] as IFeatureClass; //得到相应的要素类
                        IDataset      set         = F_class as IDataset;           //将要素类恩成数据集,以用来取得名称
                        SetCheckState.TreeCheckFun(set.Name, G, _AppHk);

                        #region 当前层共有多少要素
                        IFeatureCursor Cursor  = F_class.Search(null, false); //提供游标,用来遍历要素
                        IFeature       Feature = Cursor.NextFeature();        //开始遍历要素,取出下一个要素,这里是第一次,所以指第一个
                        while (Feature != null)
                        {
                            FeatureList.Add(Feature);
                            Feature = Cursor.NextFeature();//下一个要素
                        }

                        //释放cursor
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(Cursor);

                        #endregion
                        if (FeatureList.Count == 0)
                        {
                            pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm });//是否显示进度条,加载让它显示
                            SetCheckState.CheckShowTips(pAppForm, "空图层!");
                            continue;
                        }
                        #region 图层标准化检查
                        pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { true, pAppForm });//是否显示进度条,加载让它显示
                        for (int F = 0; F < FeatureList.Count; F++)
                        {
                            pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { FeatureList.Count, 0, 1, F + 1, pAppForm });//给进度条传需要的值
                            IFeature FeatureTemp = FeatureList[F] as IFeature;
                            int      index       = -1;
                            for (int f = 0; f < FeatureTemp.Fields.FieldCount; f++)
                            {
                                string code = FeatureTemp.Fields.get_Field(f).Name.ToLower();//将字段名换成小写
                                if (code == "code")
                                {
                                    index = f;
                                    break;
                                }
                            }
                            if (index >= 0)//必须确定表中有CODE字段列,如果没有就不执行
                            {
                                #region 图层标准化查询
                                try
                                {
                                    string value = FeatureTemp.get_Value(index).ToString(); //根据列索引得到对应的值

                                    string name = set.Name;                                 //取得要素类的名称
                                    int    ret  = BindAccess_Layer(value, name);            //将要素得到的列值进行数据库查询
                                    if (ret == -1)
                                    {
                                        string content          = name + " OID:" + FeatureTemp.OID.ToString();
                                        System.Data.DataRow Row = Datatable.NewRow();
                                        Row[0] = content;
                                        Datatable.Rows.Add(Row);
                                        SetCheckState.CheckShowTips(pAppForm, content);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _AppHk.CurrentThread = null;//如果中间出错,就结束线程
                                    MessageBox.Show(ex.ToString());
                                    return;
                                }
                                #endregion
                            }
                            else
                            {
                                break;//由于要素类的结构列是一样的,一条要素找不到对应的列,其它的也一样,所以跳出这个要素类的遍历
                            }
                        }

                        if (G == LayerList.Count)
                        {
                            SetCheckState.CheckShowTips(pAppForm, "马上完成,请稍后...");
                        }
                        #endregion
                    }
                    break;
                }
                #endregion
            }
            pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });
            pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm });//是否显示进度条,加载让它显示
            _AppHk.CurrentThread = null;
            SetCheckState.CheckShowTips(pAppForm, "代码图层标准检查完成!");
            SetCheckState.Message(pAppForm, "提示", "图层标准化检查完成!");
            //选中检查出错列表
            ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 重复线
        /// </summary>
        private void Line_redo(object para)
        {
            Plugin.Application.IAppFormRef pAppForm  = para as Plugin.Application.IAppFormRef;
            System.Data.DataTable          Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示
            Datatable.Columns.Add("重复线", typeof(string));                           //创建一列
            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();

            ClearGrid.Operate(pAppForm, _AppHk);
            #region 打开要操作的数据集
            if (_AppHk.MapControl.LayerCount == 0)
            {
                return;                                   //如果MAP上打开的图层为空,就返回
            }
            SetCheckState.CheckShowTips(pAppForm, "重复线检查开始,准备载入检查数据,请稍后.....");
            int L_count = _AppHk.MapControl.LayerCount;//MAP上总图层数
            if (L_count == 0)
            {
                return;              //当MAP上是空,就返回
            }
            IGeoDataset            pGeoDataset = SetCheckState.Geodatabase;
            ITopologyRuleContainer pRuleCont   = SetCheckState.pT as ITopologyRuleContainer;//引入拓扑规则接口对象,将拓扑转成对应的规则接口对象
            #endregion
            try
            {
                #region 遍历整个数据集要素
                ArrayList list_line = new ArrayList();//用动态的数组来接收满足线要素类的对象,以后面实现遍历拓扑检查
                for (int l = 0; l < L_count; l++)
                {
                    ILayer layer_1 = _AppHk.MapControl.get_Layer(l); //通过索引得到对应的层
                    #region                                          //判别是不是组,如果是,就从组中取一个层
                    if (layer_1 is IGroupLayer && layer_1.Name == SetCheckState.CheckDataBaseName)
                    {
                        ICompositeLayer grouplayer_1 = layer_1 as ICompositeLayer;//把组图层转成组合图层
                        int             group_count  = grouplayer_1.Count;
                        if (group_count == 0)
                        {
                            return;
                        }
                        for (int g = 0; g < group_count; g++)
                        {
                            ILayer        layer_temp    = grouplayer_1.get_Layer(g);
                            IFeatureLayer pFeaturelayer = layer_temp as IFeatureLayer;
                            IFeatureClass pFeatureClass = pFeaturelayer.FeatureClass;
                            #region 将符合线要素的类加入到拓扑中
                            if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && pFeatureClass.FeatureType != esriFeatureType.esriFTAnnotation && pFeatureClass.Search(null, false).NextFeature() != null)
                            {
                                list_line.Add(pFeatureClass);//将符合的要素类加入动态数组当中
                            }
                            #endregion
                        }
                        break;
                    }
                    #endregion
                }
                #endregion
                SetCheckState.CheckShowTips(pAppForm, "数据准备完毕,准备进度显示数据,请稍后.....");
                #region 通过过滤后的要素类来进行拓扑检查
                int Count = list_line.Count;//总要遍历的层数
                if (Count == 0)
                {
                    _AppHk.CurrentThread = null;
                    SetCheckState.CheckShowTips(pAppForm, "重复线检查完成!");
                    SetCheckState.Message(pAppForm, "提示", "线重复检查完成!");
                    //选中检查出错列表
                    ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
                    return;
                }
                SetCheckState.TreeIni_Fun(list_line, _AppHk);//初始化树
                SetCheckState.CheckShowTips(pAppForm, "进度数据准备完毕,马上进入拓扑分析,请稍后.....");
                for (int N = 0; N < Count; N++)
                {
                    IFeatureClass TempClass = list_line[N] as IFeatureClass;                    //将对象转成相应的要素类
                    IDataset      ds        = TempClass as IDataset;
                    SetCheckState.TreeCheckFun(ds.Name, N, _AppHk);                             //调用树节点选中
                    ITopologyRule topologyRule = new TopologyRuleClass();                       //实例一个拓扑规则类
                    topologyRule.TopologyRuleType  = esriTopologyRuleType.esriTRTLineNoOverlap; //使用规则的类型(线不重叠)
                    topologyRule.Name              = "www";                                     //给规则取个名
                    topologyRule.OriginClassID     = TempClass.FeatureClassID;
                    topologyRule.AllOriginSubtypes = true;
                    pRuleCont.AddRule(topologyRule);
                    ISegmentCollection pLocation = new PolygonClass();                            //使用多边形接口 实例一个面的片段
                    pLocation.SetRectangle(pGeoDataset.Extent);                                   //将我们用来操作验证的要素类利用SETRECTANGLE来构造一个完整的几何形体
                    IPolygon  pPoly          = SetCheckState.pT.get_DirtyArea(pLocation as IPolygon);
                    IEnvelope pAreaValidated = SetCheckState.pT.ValidateTopology(pPoly.Envelope); //返回利用拓扑规则验证后的出错结果

                    SetCheckState.CheckShowTips(pAppForm, "拓扑分析中,请稍后.....");
                    IErrorFeatureContainer    pErrFeatCon      = SetCheckState.pT as IErrorFeatureContainer;                                                                 //实例一个拓扑出错的容器
                    IEnumTopologyErrorFeature pEnumTopoErrFeat = pErrFeatCon.get_ErrorFeatures(pGeoDataset.SpatialReference, topologyRule, pGeoDataset.Extent, true, false); //将所有的拓扑出错进行枚举
                    int num = N + 1;                                                                                                                                         //由于层的索引是从0开始的,所以得加1

                    ITopologyErrorFeature Topo_ErrFeat = pEnumTopoErrFeat.Next();                                                                                            //开始遍历拓扑错误,表示下一个s
                    ArrayList             TempTopList  = new ArrayList();
                    //将当前层的所有出错要素放入动态数组当中
                    while (Topo_ErrFeat != null)
                    {
                        TempTopList.Add(Topo_ErrFeat);//将出错的要素存入动态数组
                        Topo_ErrFeat = pEnumTopoErrFeat.Next();
                    }
                    SetCheckState.CheckShowTips(pAppForm, "拓扑分析完毕,进行具体检查操作,请稍后.....");
                    int P_count = TempTopList.Count;//每个层的总出错记录
                    if (P_count == 0)
                    {
                        SetCheckState.CheckShowTips(pAppForm, "无重复线准备进行下一个图层操作,请稍后....");
                        continue;
                    }
                    SetCheckState.CheckShowTips(pAppForm, "正在进行" + TempClass.AliasName + "图层操作,请稍后....");
                    pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { true, pAppForm });//是否显示进度条,加载让它显示
                    #region 遍历出错
                    for (int p = 0; p < P_count; p++)
                    {
                        int i = p + 1;                                                                                            //方便计算
                        pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { P_count, 0, 1, i, pAppForm }); //给进度条传需要的值
                        ITopologyErrorFeature pTopoErrFeat = TempTopList[p] as ITopologyErrorFeature;
                        int OriginOID = pTopoErrFeat.OriginOID;                                                                   //源ID

                        int      DestinationOID = pTopoErrFeat.DestinationOID;                                                    //目标ID
                        IFeature source_fe      = TempClass.GetFeature(OriginOID);                                                //源要素
                        IFeature des_fe         = TempClass.GetFeature(DestinationOID);                                           //目标要素

                        ///求几何空间差值,必须要两种情况考虑:a->b  b->a,如果同时都为空,说明两个重复
                        ITopologicalOperator Origin_0     = des_fe.Shape as ITopologicalOperator;              //空间几何运算
                        IGeometry            difference_0 = Origin_0.Difference(source_fe.Shape as IGeometry); //求两个面的差值

                        ITopologicalOperator Origin     = source_fe.Shape as ITopologicalOperator;             //空间几何运算
                        IGeometry            difference = Origin.Difference(des_fe.Shape as IGeometry);        //求两个面的差值

                        if (difference.IsEmpty && difference_0.IsEmpty)
                        {
                            StringBuilder origin_temp      = new StringBuilder(); //除了SHAPE外的字段对比源
                            StringBuilder destination_temp = new StringBuilder(); //除了SHAPE外的字段对比目标

                            ArrayList list  = Foreach();                          //得到我们需要遍历的对比字段
                            int       count = list.Count;
                            if (count > 0)
                            {
                                for (int n = 0; n < count; n++)
                                {
                                    int index = TempClass.GetFeature(OriginOID).Fields.FindFieldByAliasName(list[n].ToString());       //查看我们要对比的字段名是不是存在 源

                                    int index1 = TempClass.GetFeature(DestinationOID).Fields.FindFieldByAliasName(list[n].ToString()); //查看我们要对比的字段名是不是存在 目标
                                    if (index >= 0 && index1 >= 0)
                                    {
                                        origin_temp.Append(TempClass.GetFeature(OriginOID).get_Value(index));
                                        destination_temp.Append(TempClass.GetFeature(DestinationOID).get_Value(index1));
                                    }
                                }
                                if (origin_temp.Equals(destination_temp) && origin_temp != null && destination_temp != null)
                                {
                                    string temp             = ds.Name + " ID:" + OriginOID.ToString() + " 目标ID:" + DestinationOID.ToString();
                                    System.Data.DataRow Row = Datatable.NewRow();
                                    Row[0] = temp;
                                    Datatable.Rows.Add(Row);
                                    SetCheckState.CheckShowTips(pAppForm, temp);
                                }
                                else
                                {
                                    pTopoErrFeat = pEnumTopoErrFeat.Next();
                                    continue;
                                }
                            }
                            else
                            {
                                string temp             = ds.Name + " ID:" + OriginOID.ToString() + " 目标ID:" + DestinationOID.ToString();
                                System.Data.DataRow Row = Datatable.NewRow();
                                Row[0] = temp;
                                Datatable.Rows.Add(Row);
                                SetCheckState.CheckShowTips(pAppForm, temp);
                            }
                        }
                    }
                    #endregion

                    pRuleCont.DeleteRule(topologyRule);//移除拓扑规则

                    if (num == Count)
                    {
                        SetCheckState.CheckShowTips(pAppForm, "重复线检查马上完成,请稍后....");
                        break;
                    }
                }
                pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //显示完成隐藏进度条
                pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });             //将窗体控件进行方法的委托,因为得让它成为安全的
                _AppHk.CurrentThread = null;                                                                     //将线程置空
                SetCheckState.CheckShowTips(pAppForm, "重复线检查完成!");
                SetCheckState.Message(pAppForm, "提示", "线重复检查完成!");
                //选中检查出错列表
                ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
                #endregion
            }
            catch (Exception ex)
            {
                _AppHk.CurrentThread = null;//将线程置空
                MessageBox.Show(ex.ToString());
                return;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修正处理函数,参数框架为主窗体,以获得图层(取得待处理的要素)和进度条

        /// </summary>
        /// <param name="AppHook"></param>

        private void ExcuteCorrect(object hook)
        {
            SetCheckState.GeoCor = true;//拓扑修正里用到开启和关闭编辑
            Plugin.Application.IAppGISRef AppHook = hook as Plugin.Application.IAppGISRef;
            #region 取得进度条对象

            //取得进度条对象

            Plugin.Application.IAppFormRef pAppForm = AppHook as Plugin.Application.IAppFormRef;
            #endregion
            Plugin.Application.IAppGISRef appHook = hook as Plugin.Application.IAppGISRef;

            #region 获得待处理的图层

            //判断图层个数是否为0
            if (AppHook.MapControl.LayerCount == 0)
            {
                return;
            }
            IWorkspaceEdit pWorkspaceEdit = null;

            #region 循环图层进行处理,并控制进度条

            for (int i = 0; i < AppHook.MapControl.LayerCount; i++)
            {
                ESRI.ArcGIS.Carto.ILayer pLayer = AppHook.MapControl.get_Layer(i);
                bool isShpFile = false;

                //操作更新库体下的层 && pLayer.Name == SetCheckState.CheckDataBaseName

                #region 针对的是IGrouplayer下的层进行拓扑修正
                if (pLayer is IGroupLayer)
                {
                    ICompositeLayer C_layer = pLayer as ICompositeLayer;
                    int             count   = C_layer.Count;//得到组合图层数
                    if (count == 0)
                    {
                        return;
                    }
                    for (int c = 0; c < count; c++)
                    {
                        ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = C_layer.get_Layer(c) as IFeatureLayer;
                        #region 图形简单化,删除空图形,删除零长度线,删除零面积面,负面积面逆向
                        if (pFeatLayer == null)
                        {
                            continue;
                        }
                        IFeatureClass pFeatureClass = pFeatLayer.FeatureClass;

                        //开启编辑  wjj 20090921
                        IDataset pDataset = pFeatureClass as IDataset;
                        pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;
                        if (pWorkspaceEdit.IsBeingEdited() == false)
                        {
                            pWorkspaceEdit.StartEditing(false);
                        }

                        //判断图层类型,线或者面才进行处理

                        if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                        {
                            IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        //删除空几何图形

                                        if (pFeat.Shape.IsEmpty)
                                        {
                                            pFeat.Delete();
                                            //写状态栏信息
                                            string del = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, del);
                                        }
                                        else
                                        {
                                            ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                            if (pTopo != null)
                                            {
                                                //图形简单化
                                                pTopo.Simplify();
                                                //写状态栏信息
                                                string simplify = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                                SetCheckState.CheckShowTips(pAppForm, simplify);
                                            }
                                        }

                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #region  除长度为零的线要素
                            //删除长度为零的要素

                            IQueryFilter pFilter = new QueryFilterClass();
                            pFilter.WhereClause = pFeatureClass.LengthField.Name + "=0 or " + pFeatureClass.LengthField.Name + " is null";

                            pFeatCur = pFeatureClass.Search(pFilter, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string zero = pFeatureClass.AliasName + ": 删除长度为零的线要素,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, zero);
                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #endregion

                            //释放cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
                        }
                        else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                        {
                            IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);
                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        //删除空几何图形

                                        if (pFeat.Shape.IsEmpty)
                                        {
                                            pFeat.Delete();
                                            //写状态栏信息
                                            string delps = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, delps);
                                        }
                                        else
                                        {
                                            ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                            if (pTopo != null)
                                            {
                                                //图形简单化
                                                pTopo.Simplify();
                                                //写状态栏信息
                                                string simplifyps = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                                SetCheckState.CheckShowTips(pAppForm, simplifyps);
                                            }
                                        }

                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #region 负面积面点序逆向
                            IQueryFilter pFilter = new QueryFilterClass();
                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "<0";

                            pFeatCur = pFeatureClass.Search(pFilter, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();
                                if (pFeat != null)
                                {
                                    do
                                    {
                                        //点序逆向
                                        ICurve pCurv = pFeat.Shape as ICurve;

                                        if (pCurv != null)
                                        {
                                            pCurv.ReverseOrientation();
                                            pFeat.Shape = pCurv;
                                            pFeat.Store();
                                            //写状态栏信息
                                            string reverse = pFeatureClass.AliasName + ": 点序逆向,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, reverse);
                                        }

                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #endregion

                            //删除面积为零的要素

                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "=0 or " + pFeatureClass.AreaField.Name + " is null";

                            pFeatCur = pFeatureClass.Search(pFilter, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string delarea = pFeatureClass.AliasName + ": 删除面积为零的要素,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, delarea);
                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            //释放cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);

                            #endregion
                        }

                        //结束编辑 wjj 20090921
                        if (pWorkspaceEdit.IsBeingEdited() == true)
                        {
                            pWorkspaceEdit.StopEditing(true);
                        }
                    }
                    SetCheckState.CheckShowTips(pAppForm, "拓扑修正检查完成!");
                    appHook.CurrentThread = null;
                    SetCheckState.Message(pAppForm, "提示", "拓扑修正检查完成!");
                    SetCheckState.GeoCor = false;//用完判断是否有编辑操作状态后还原
                    break;
                }
                #endregion
                else
                {
                    ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = pLayer as IFeatureLayer;
                    #region 图形简单化,删除空图形,删除零长度线,删除零面积面,负面积面逆向
                    if (pFeatLayer == null)
                    {
                        continue;
                    }
                    IFeatureClass pFeatureClass = pFeatLayer.FeatureClass;

                    //开启编辑  wjj 20090921
                    IDataset pDataset = pFeatureClass as IDataset;

                    #region 陈胜鹏添加shp文件类型的判断 2010-3-10
                    if (pFeatLayer.DataSourceType == "Shapefile Feature Class")
                    {
                        isShpFile = true;
                    }
                    #endregion

                    pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;
                    if (pWorkspaceEdit.IsBeingEdited() == false)
                    {
                        pWorkspaceEdit.StartEditing(false);
                    }

                    //判断图层类型,线或者面才进行处理

                    if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    //删除空几何图形

                                    if (pFeat.Shape.IsEmpty)
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string del = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, del);
                                    }
                                    else
                                    {
                                        ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                        if (pTopo != null)
                                        {
                                            //图形简单化
                                            pTopo.Simplify();
                                            //写状态栏信息
                                            string simplify = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, simplify);
                                        }
                                    }

                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #region  除长度为零的线要素
                        //删除长度为零的要素

                        IQueryFilter pFilter = new QueryFilterClass();

                        if (isShpFile)
                        {
                            pFilter.WhereClause = "SHAPE_Leng" + "=0 or " + "SHAPE_Leng" + " is null";
                        }
                        else
                        {
                            pFilter.WhereClause = pFeatureClass.LengthField.Name + "=0 or " + pFeatureClass.LengthField.Name + " is null";
                        }

                        pFeatCur = pFeatureClass.Search(pFilter, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    pFeat.Delete();
                                    //写状态栏信息
                                    string zero = pFeatureClass.AliasName + ": 删除长度为零的线要素,OID:" + pFeat.OID;
                                    SetCheckState.CheckShowTips(pAppForm, zero);
                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #endregion

                        //释放cursor
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
                    }
                    else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);
                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    //删除空几何图形

                                    if (pFeat.Shape.IsEmpty)
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string delps = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, delps);
                                    }
                                    else
                                    {
                                        ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                        if (pTopo != null)
                                        {
                                            //图形简单化
                                            pTopo.Simplify();
                                            //写状态栏信息
                                            string simplifyps = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, simplifyps);
                                        }
                                    }

                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #region 负面积面点序逆向
                        IQueryFilter pFilter = new QueryFilterClass();

                        if (isShpFile)
                        {
                            pFilter.WhereClause = "SHAPE_Area" + "<0";
                        }
                        else
                        {
                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "<0";
                        }

                        pFeatCur = pFeatureClass.Search(pFilter, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();
                            if (pFeat != null)
                            {
                                do
                                {
                                    //点序逆向
                                    ICurve pCurv = pFeat.Shape as ICurve;

                                    if (pCurv != null)
                                    {
                                        pCurv.ReverseOrientation();
                                        pFeat.Shape = pCurv;
                                        pFeat.Store();
                                        //写状态栏信息
                                        string reverse = pFeatureClass.AliasName + ": 点序逆向,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, reverse);
                                    }

                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #endregion

                        //删除面积为零的要素

                        if (isShpFile)
                        {
                            pFilter.WhereClause = "SHAPE_Area" + "=0 or " + "SHAPE_Area" + " is null";
                        }
                        else
                        {
                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "=0 or " + pFeatureClass.AreaField.Name + " is null";
                        }

                        pFeatCur = pFeatureClass.Search(pFilter, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    pFeat.Delete();
                                    //写状态栏信息
                                    string delarea = pFeatureClass.AliasName + ": 删除面积为零的要素,OID:" + pFeat.OID;
                                    SetCheckState.CheckShowTips(pAppForm, delarea);
                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }
                        //释放cursor
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
                    }
                    #endregion
                }
            }
            //结束编辑 wjj 20090921
            if (pWorkspaceEdit.IsBeingEdited() == true)
            {
                pWorkspaceEdit.StopEditing(true);
                SetCheckState.CheckShowTips(pAppForm, "拓扑修正检查完成!");
                appHook.CurrentThread = null;
                SetCheckState.Message(pAppForm, "提示", "拓扑修正检查完成!");
                SetCheckState.GeoCor = false;//用完判断是否有编辑操作状态后还原
            }
            #endregion
            #endregion
        }
        /// <summary>
        /// 重复面
        /// </summary>
        private void Cover(object para)
        {
            Plugin.Application.IAppFormRef pAppForm  = para as Plugin.Application.IAppFormRef;
            System.Data.DataTable          Datatable = new System.Data.DataTable();//手动建立一个数据表,将得到的数据邦定到检查结果当中显示

            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();

            ClearGrid.Operate(pAppForm, _AppHk);
            Datatable.Columns.Add("重复面", typeof(string));//创建一列

            #region 打开要操作的数据集

            int L_count = _AppHk.MapControl.LayerCount;//MAP上总图层数
            if (L_count == 0)
            {
                return;              //当MAP上是空,就返回
            }
            SetCheckState.CheckShowTips(pAppForm, "面重复检查开始......");
            IGeoDataset            pGeoDataset = SetCheckState.Geodatabase;
            ITopologyRuleContainer pRuleCont   = SetCheckState.pRuleCont;//引入拓扑规则接口对象,将拓扑转成对应的规则接口对象
            #endregion
            try
            {
                #region 遍历整个数据集要素
                ArrayList list_line = new ArrayList();//用动态的数组来接收满足线要素类的对象,以后面实现遍历拓扑检查
                for (int l = 0; l < L_count; l++)
                {
                    ILayer layer_1 = _AppHk.MapControl.get_Layer(l); //通过索引得到对应的层
                    #region                                          //判别是不是组,如果是,就从组中取一个层
                    if (layer_1 is IGroupLayer && layer_1.Name == SetCheckState.CheckDataBaseName)
                    {
                        ICompositeLayer grouplayer_1 = layer_1 as ICompositeLayer;//把组图层转成组合图层
                        int             group_count  = grouplayer_1.Count;
                        if (group_count == 0)
                        {
                            return;
                        }
                        for (int g = 0; g < group_count; g++)
                        {
                            ILayer        layer_temp    = grouplayer_1.get_Layer(g);
                            IFeatureLayer pFeaturelayer = layer_temp as IFeatureLayer;
                            IFeatureClass pFeatureClass = pFeaturelayer.FeatureClass;
                            #region 将符合线要素的类加入到拓扑中
                            if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && pFeatureClass.FeatureType != esriFeatureType.esriFTAnnotation && pFeatureClass.Search(null, false).NextFeature() != null)
                            {
                                list_line.Add(pFeatureClass);//将符合的要素类加入动态数组当中
                            }
                            #endregion
                        }
                    }
                    #endregion
                }
                #endregion
                int Count = list_line.Count;
                if (Count == 0)
                {
                    SetCheckState.CheckShowTips(pAppForm, "重复面检查完成!");
                    _AppHk.CurrentThread = null;
                    SetCheckState.Message(pAppForm, "提示", "面重复检查完成!");
                    //选中检查出错列表
                    ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
                    return;
                }
                if (Count == 0)
                {
                    return;
                }
                SetCheckState.TreeIni_Fun(list_line, _AppHk);//初始化树图
                SetCheckState.CheckShowTips(pAppForm, "检查数据准备完毕,请稍后........");
                #region 通过过滤后的要素类来进行拓扑检查
                for (int N = 0; N < Count; N++)
                {
                    int num = N + 1;//由于层的索引是从0开始的,所以得加1

                    #region 创建拓扑并验证拓扑
                    IFeatureClass TempClass = list_line[N] as IFeatureClass;                    //将对象转成相应的要素类
                    IDataset      ds        = TempClass as IDataset;
                    SetCheckState.TreeCheckFun(ds.Name, N, _AppHk);                             //调用树节点选中方法
                    ITopologyRule topologyRule = new TopologyRuleClass();                       //实例一个拓扑规则类
                    topologyRule.TopologyRuleType  = esriTopologyRuleType.esriTRTAreaNoOverlap; //使用规则的类型(面不相交)
                    topologyRule.Name              = "www";                                     //给规则取个名
                    topologyRule.OriginClassID     = TempClass.FeatureClassID;
                    topologyRule.AllOriginSubtypes = true;
                    pRuleCont.AddRule(topologyRule);


                    ISegmentCollection pLocation = new PolygonClass();                            //使用多边形接口
                    pLocation.SetRectangle(pGeoDataset.Extent);                                   //将我们用来操作验证的要素类利用SETRECTANGLE来构造一个完整的几何形体
                    IPolygon  pPoly          = SetCheckState.pT.get_DirtyArea(pLocation as IPolygon);
                    IEnvelope pAreaValidated = SetCheckState.pT.ValidateTopology(pPoly.Envelope); //验证拓扑

                    SetCheckState.CheckShowTips(pAppForm, "正在进行拓扑分析,请稍后........");
                    IErrorFeatureContainer    pErrFeatCon      = SetCheckState.pT as IErrorFeatureContainer;                                                                 //实例一个拓扑出错的容器
                    IEnumTopologyErrorFeature pEnumTopoErrFeat = pErrFeatCon.get_ErrorFeatures(pGeoDataset.SpatialReference, topologyRule, pGeoDataset.Extent, true, false); //将所有的拓扑出错进行枚举
                    #endregion

                    ITopologyErrorFeature Topo_ErrFeat = pEnumTopoErrFeat.Next();//开始遍历拓扑错误,表示下一个s
                    ArrayList             TempTopList  = new ArrayList();
                    //将当前层的所有出错要素放入动态数组当中
                    while (Topo_ErrFeat != null)
                    {
                        TempTopList.Add(Topo_ErrFeat);//将出错的要素存入动态数组
                        Topo_ErrFeat = pEnumTopoErrFeat.Next();
                    }
                    int P_count = TempTopList.Count;//每个层的总出错记录
                    if (P_count == 0)
                    {
                        SetCheckState.CheckShowTips(pAppForm, "图层完好,准备进行下一个图层,请稍后........");
                        continue;
                    }
                    pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { true, pAppForm });//是否显示进度条,加载让它显示
                    #region 遍历出错
                    for (int p = 0; p < P_count; p++)
                    {
                        int i = p + 1;                                                                                            //方便计算
                        pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { P_count, 0, 1, i, pAppForm }); //给进度条传需要的值
                        ITopologyErrorFeature pTopoErrFeat = TempTopList[p] as ITopologyErrorFeature;
                        int      OriginOID      = pTopoErrFeat.OriginOID;                                                         //源ID
                        int      DestinationOID = pTopoErrFeat.DestinationOID;                                                    //目标ID
                        IFeature source_fe      = TempClass.GetFeature(OriginOID);                                                //源要素
                        IFeature des_fe         = TempClass.GetFeature(DestinationOID);                                           //目标要素
                        #region 通过拓扑出来的错进行再次分析求重复面
                        ///求几何空间差值,必须要两种情况考虑:a->b  b->a,如果同时都为空,说明两个重复
                        ITopologicalOperator Origin_0     = des_fe.Shape as ITopologicalOperator;              //空间几何运算
                        IGeometry            difference_0 = Origin_0.Difference(source_fe.Shape as IGeometry); //求两个面的差值

                        ITopologicalOperator Origin     = source_fe.Shape as ITopologicalOperator;             //空间几何运算
                        IGeometry            difference = Origin.Difference(des_fe.Shape as IGeometry);        //求两个面的差值


                        if (difference.IsEmpty && difference_0.IsEmpty)
                        {
                            #region MyRegion
                            //    StringBuilder origin_temp = new StringBuilder();//除了SHAPE外的字段对比源
                            //    StringBuilder destination_temp = new StringBuilder();//除了SHAPE外的字段对比目标
                            //    //IDataset ds = TempClass as IDataset;
                            //    ArrayList list = Foreach();//调用要对比的XML文件里的字段名
                            //    int count = list.Count;
                            //    #region 通过拓扑出错及对出错的对象再次的进行差值及字段对比,得出最终的结果是否一样
                            //    if (count > 0)
                            //    {
                            //        #region 得到要实际比较的字段值
                            //        for (int n = 0; n < count; n++)
                            //        {
                            //            int index = TempClass.GetFeature(OriginOID).Fields.FindFieldByAliasName(list[n].ToString());//得到源的列ID

                            //            int index1 = TempClass.GetFeature(DestinationOID).Fields.FindFieldByAliasName(list[n].ToString());//得到目标的列ID
                            //            if (index > 0 && index1 > 0)
                            //            {
                            //                origin_temp.Append(TempClass.GetFeature(OriginOID).get_Value(index));//在对应的要素类当中取出源对应ID列的值,加入BUILDER中
                            //                destination_temp.Append(TempClass.GetFeature(DestinationOID).get_Value(index1));//在对应的要素类当中取出目标对应的ID列值,加入目录的BUILDER中
                            //            }
                            //        }
                            //        #endregion
                            //        #region 比较两个值是否一样
                            //        if (origin_temp.ToString() == destination_temp.ToString() && origin_temp != null && destination_temp != null)//将两个列的值进行对比
                            //        {
                            #endregion
                            string temp             = ds.Name + " ID:" + OriginOID.ToString() + " 目标ID:" + DestinationOID.ToString();
                            System.Data.DataRow Row = Datatable.NewRow(); //新创建一个行
                            Row[0] = temp;
                            Datatable.Rows.Add(Row);                      //将行加入到表数据集中
                            SetCheckState.CheckShowTips(pAppForm, temp);
                            #region
                            //        }
                            //        else
                            //        {
                            //            pTopoErrFeat = pEnumTopoErrFeat.Next();//遍历下一个错误
                            //            continue;
                            //        }
                            //        #endregion
                            //    }
                            //    else
                            //    {
                            //        string temp = ds.Name + " ID:" + OriginOID.ToString() + " 目标ID:" + DestinationOID.ToString();//将结果组织起来,放到一个字符串当中
                            //        System.Data.DataRow Row = Datatable.NewRow();//新创建一个行
                            //        Row[0] = temp;
                            //        Datatable.Rows.Add(Row);//将行加入到表数据集中
                            //    }
                            #endregion
                        }
                        #endregion
                    }

                    pRuleCont.DeleteRule(topologyRule);
                    #endregion
                    if (num == Count)
                    {
                        string Case = "马上完成请稍后.....";//状态栏显示
                        SetCheckState.CheckShowTips(pAppForm, Case);
                    }
                }
                #endregion
                pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });             //将窗体控件使用委托
                pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //是否显示进度条,加载让它显示
                _AppHk.CurrentThread = null;
                SetCheckState.Message(pAppForm, "提示", "面重复检查完成!");
                //选中检查出错列表
                SetCheckState.CheckShowTips(pAppForm, "面重复检查完成!");
                ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
            }
            catch (Exception ex)
            {
                _AppHk.CurrentThread = null;
                SetCheckState.Message(pAppForm, "错误", ex.ToString());
                return;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 悬挂点
        /// </summary>
        private void Point_dangles(object par)
        {
            Plugin.Application.IAppFormRef pAppForm  = par as Plugin.Application.IAppFormRef;
            System.Data.DataTable          Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示
            Datatable.Columns.Add("悬挂点重复", typeof(string));                         //创建一列
            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();

            ClearGrid.Operate(pAppForm, _AppHk);
            #region 打开要操作的数据集
            if (_AppHk.MapControl.LayerCount == 0)
            {
                return;                                   //如果MAP上打开的图层为空,就返回
            }
            SetCheckState.CheckShowTips(pAppForm, "悬挂点重复检查开始.....");
            int L_count = _AppHk.MapControl.LayerCount;//MAP上总图层数
            if (L_count == 0)
            {
                return;              //当MAP上是空,就返回
            }
            IGeoDataset            pGeoDataset = SetCheckState.Geodatabase;
            ITopologyRuleContainer pRuleCont   = SetCheckState.pT as ITopologyRuleContainer;//引入拓扑规则接口对象,将拓扑转成对应的规则接口对象

            #endregion
            try
            {
                #region 遍历整个数据集要素
                ArrayList list_line = new ArrayList();//用动态的数组来接收满足线要素类的对象,以后面实现遍历拓扑检查
                for (int l = 0; l < L_count; l++)
                {
                    ILayer layer_1 = _AppHk.MapControl.get_Layer(l); //通过索引得到对应的层
                    #region                                          //判别是不是组,如果是,就从组中取一个层
                    if (layer_1 is IGroupLayer)
                    {
                        ICompositeLayer grouplayer_1 = layer_1 as ICompositeLayer;//把组图层转成组合图层
                        int             group_count  = grouplayer_1.Count;
                        if (group_count == 0)
                        {
                            return;
                        }
                        for (int g = 0; g < group_count; g++)
                        {
                            ILayer        layer_temp    = grouplayer_1.get_Layer(g);
                            IFeatureLayer pFeaturelayer = layer_temp as IFeatureLayer;
                            IFeatureClass pFeatureClass = pFeaturelayer.FeatureClass;
                            #region 将符合线要素的类加入到拓扑中
                            if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && pFeatureClass.FeatureType != esriFeatureType.esriFTAnnotation && pFeatureClass.Search(null, false).NextFeature() != null)
                            {
                                list_line.Add(pFeatureClass);//将符合的要素类加入动态数组当中
                            }
                            #endregion
                        }
                    }
                    #endregion
                }
                #endregion
                int Count = list_line.Count;//得到拓扑层的总数
                if (Count == 0)
                {
                    return;
                }
                SetCheckState.TreeIni_Fun(list_line, _AppHk);//实始化树图
                #region 通过过滤后的要素类来进行拓扑检查
                for (int N = 0; N < Count; N++)
                {
                    int           num       = N + 1;                                            //由于层的索引是从0开始的,所以得加1
                    IFeatureClass TempClass = list_line[N] as IFeatureClass;                    //将对象转成相应的要素类
                    IDataset      ds        = TempClass as IDataset;
                    SetCheckState.TreeCheckFun(ds.Name, N, _AppHk);                             //调用节点选中方法
                    ITopologyRule topologyRule = new TopologyRuleClass();                       //实例一个拓扑规则类
                    topologyRule.TopologyRuleType  = esriTopologyRuleType.esriTRTLineNoDangles; //使用规则的类型(悬挂点)
                    topologyRule.Name              = "www";                                     //给规则取个名
                    topologyRule.OriginClassID     = TempClass.FeatureClassID;
                    topologyRule.AllOriginSubtypes = true;
                    pRuleCont.AddRule(topologyRule);


                    ISegmentCollection pLocation = new PolygonClass(); //使用多边形接口
                    pLocation.SetRectangle(pGeoDataset.Extent);        //将我们用来操作验证的要素类利用SETRECTANGLE来构造一个完整的几何形体
                    IPolygon  pPoly          = SetCheckState.pT.get_DirtyArea(pLocation as IPolygon);
                    IEnvelope pAreaValidated = SetCheckState.pT.ValidateTopology(pPoly.Envelope);

                    IErrorFeatureContainer    pErrFeatCon      = SetCheckState.pT as IErrorFeatureContainer;                                                                 //实例一个拓扑出错的容器
                    IEnumTopologyErrorFeature pEnumTopoErrFeat = pErrFeatCon.get_ErrorFeatures(pGeoDataset.SpatialReference, topologyRule, pGeoDataset.Extent, true, false); //将所有的拓扑出错进行枚举

                    ITopologyErrorFeature Topo_ErrFeat = pEnumTopoErrFeat.Next();                                                                                            //开始遍历拓扑错误,表示下一个s
                    ArrayList             TempTopList  = new ArrayList();
                    while (Topo_ErrFeat != null)
                    {
                        TempTopList.Add(Topo_ErrFeat);//将出错的要素存入动态数组
                        Topo_ErrFeat = pEnumTopoErrFeat.Next();
                    }
                    #region 遍历出错
                    int P_count = TempTopList.Count;//每个层的总出错记录
                    if (P_count == 0)
                    {
                        pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm });//是否显示进度条,加载让它显示
                        SetCheckState.CheckShowTips(pAppForm, "图层完好,无悬挂点!");
                        continue;
                    }
                    pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { true, pAppForm });//是否显示进度条,加载让它显示
                    #region 遍历错误
                    for (int p = 0; p < P_count; p++)
                    {
                        int i = p + 1;                                                                                            //方便计算
                        pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { P_count, 0, 1, i, pAppForm }); //给进度条传需要的值
                        ITopologyErrorFeature pTopoErrFeat = TempTopList[p] as ITopologyErrorFeature;
                        int OriginOID = pTopoErrFeat.OriginOID;                                                                   //源ID
                        if (i % 2 != 0)
                        {
                            string temp             = ds.Name + " 悬挂ID:" + OriginOID.ToString();
                            System.Data.DataRow Row = Datatable.NewRow(); //新创建一个行
                            Row[0] = temp;
                            Datatable.Rows.Add(Row);                      //将行加入到表数据集中
                            SetCheckState.CheckShowTips(pAppForm, temp);
                        }
                    }
                    #endregion

                    pRuleCont.DeleteRule(topologyRule);//删除拓扑规则
                    if (num == Count)
                    {
                        SetCheckState.CheckShowTips(pAppForm, "马上完成,请稍后....");
                    }
                    #endregion
                }
                #endregion
                pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });             //将窗体控件使用委托
                pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //是否显示进度条,加载让不显示
                SetCheckState.CheckShowTips(pAppForm, "悬挂点检查完成!");
                _AppHk.CurrentThread = null;
                SetCheckState.Message(pAppForm, "提示", "悬挂点检查完成!");
                //选中检查出错列表
                ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
            }
            catch (Exception ex)
            {
                _AppHk.CurrentThread = null;
                MessageBox.Show(ex.ToString());
                return;
            }
        }
        /// <summary>
        /// 判断重复点
        /// </summary>
        private void RePoint(IFeatureClass pFeatureclass, Plugin.Application.IAppFormRef pAppForm, System.Data.DataTable Datatable, int index)
        {
            #region point
            try
            {
                #region 读XML内容
                string[]  para;
                ArrayList list = new ArrayList();
                list = Foreach();
                if (list != null)
                {
                    int list_count = list.Count;
                    para = new string[list_count];
                    for (int num = 0; num < list_count; num++)
                    {
                        para[num] = list[num].ToString();
                    }
                }
                else
                {
                    para = new string[0];
                }
                #endregion
                list = null;
                Hashtable     Foreach_hs    = new Hashtable();       //用一个哈希来遍历重复
                IFeatureClass pFeatureClass = pFeatureclass;         //要素类
                IDataset      set           = pFeatureClass as IDataset;
                SetCheckState.TreeCheckFun(set.Name, index, _AppHk); //选中节点
                //开始遍历
                #region 遍历要素类
                IFeatureCursor cour        = pFeatureClass.Search(null, false);
                IFeature       fu          = cour.NextFeature();
                ArrayList      FeatureList = new ArrayList();//存要素动态数组
                //将当前要素类里的所有要素存入动态数组
                while (fu != null)
                {
                    FeatureList.Add(fu);
                    fu = cour.NextFeature();
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(cour);

                //如果为空,就返回
                int FeatureCount = FeatureList.Count;
                if (FeatureCount == 0)
                {
                    pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm });//是否显示进度条,加载让它显示
                    SetCheckState.CheckShowTips(pAppForm, "图层完好,无重复点!");
                    return;
                }
                #region 遍历要素类里的重复点
                pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { true, pAppForm });//是否显示进度条,加载让它显示
                for (int F = 0; F < FeatureCount; F++)
                {
                    fu = FeatureList[F] as IFeature;
                    int i = F + 1;                                                                                                 //方便计算
                    pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { FeatureCount, 0, 1, i, pAppForm }); //给进度条传需要的值
                    #region 总体上得到一个比较值,然后加入到LIST当中
                    IPoint point = fu.Shape as IPoint;
                    double x     = point.X;
                    double y     = point.Y;
                    string temp  = x.ToString() + "," + y.ToString();
                    #region 从XML里提取要比较字段
                    int C = para.Length;
                    if (C > 0)
                    {
                        for (int n = 0; n < C; n++)
                        {
                            int ID = fu.Fields.FindField(para[n]);//得到OID
                            if (ID >= 0)
                            {
                                string content = fu.get_Value(ID).ToString();//得到对应字段的值
                                temp = temp + "," + content;
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                    #endregion
                    #endregion
                    string soruce = set.Name + " 源OID:" + fu.OID.ToString();
                    if (Foreach_hs == null)
                    {
                        Foreach_hs.Add(temp, soruce);
                    }
                    else
                    {
                        if (!Foreach_hs.Contains(temp))
                        {
                            Foreach_hs.Add(temp, soruce);
                        }
                        else
                        {
                            string values = Foreach_hs[temp].ToString();                       //取得源重复的OID和NAME

                            string temps            = values + " 重复的OID:" + fu.OID.ToString(); //组合信息
                            System.Data.DataRow Row = Datatable.NewRow();                      //新创建一个行
                            Row[0] = temps;
                            Datatable.Rows.Add(Row);                                           //将行加入到表数据集中
                            SetCheckState.CheckShowTips(pAppForm, temps);
                        }
                    }
                }
                #endregion

                SetCheckState.CheckShowTips(pAppForm, "正在进行下一个图层操作,请稍后....");
                #endregion
            }
            catch (Exception ex)
            {
                _AppHk.CurrentThread = null;
                MessageBox.Show(ex.ToString());
                return;
            }
            #endregion
        }
        /// <summary>
        /// 点重复数字化检查主函数
        /// </summary>
        /// <param name="_AppHk"></param>
        private void ExcutePointDigitalDuplicateCheck(object Hook)
        {
            Plugin.Application.IAppGISRef _AppHk = Hook as Plugin.Application.IAppGISRef;

            #region 取得进度条对象

            //取得进度条对象

            Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;
            #endregion
            System.Data.DataTable Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示
            Datatable.Columns.Add("重复点", typeof(string));                  //创建一列

            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();
            ClearGrid.Operate(pAppForm, _AppHk);
            //判断图层个数是否为0
            if (_AppHk.MapControl.LayerCount == 0)
            {
                return;
            }
            SetCheckState.CheckShowTips(pAppForm, "重复点检查开始.....");
            int Count = _AppHk.MapControl.LayerCount;
            for (int i = 0; i < Count; i++)
            {
                ILayer temp_layer = _AppHk.MapControl.get_Layer(i);
                //判别是不是组,如果是,就从组中取一个层
                if (temp_layer is IGroupLayer && temp_layer.Name == SetCheckState.CheckDataBaseName)
                {
                    ICompositeLayer grouplayer = temp_layer as ICompositeLayer; //把组图层转成组合图层
                    int             C_count    = grouplayer.Count;              //组合图层数
                    if (C_count == 0)
                    {
                        return;
                    }
                    #region 遍历组下面的重复点
                    ArrayList LayerList = new ArrayList();//存要素类
                    //将所有可用的图层存入动态数组
                    for (int c = 0; c < C_count; c++)
                    {
                        //图层转换
                        pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { C_count, 0, 1, c, pAppForm }); //给进度条传需要的值
                        int num = c + 1;                                                                                          //由于层的索引是从0开始的,所以得加1
                        ESRI.ArcGIS.Carto.ILayer        pLayer     = grouplayer.get_Layer(c);
                        ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = pLayer as ESRI.ArcGIS.Carto.IFeatureLayer;
                        //如果图层不为空,就转成对应的要素类
                        if (pFeatLayer == null)
                        {
                            continue;
                        }
                        IFeatureClass pFeatureClass = pFeatLayer.FeatureClass;
                        if (pFeatureClass == null)
                        {
                            continue;
                        }
                        //只取点层
                        if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPoint && pFeatureClass.FeatureType != esriFeatureType.esriFTAnnotation)
                        {
                            LayerList.Add(pFeatureClass);//加入动态数组中
                        }
                    }
                    SetCheckState.TreeIni_Fun(LayerList, _AppHk);//初始化树
                    //重复点检查操作
                    for (int L = 0; L < LayerList.Count; L++)
                    {
                        IFeatureClass pFeatureClass = LayerList[L] as IFeatureClass;
                        RePoint(pFeatureClass, pAppForm, Datatable, L);//开始遍历重复点
                        if (L == LayerList.Count - 1)
                        {
                            SetCheckState.CheckShowTips(pAppForm, "重复点检查马上完成,请稍后...");
                        }
                    }
                    #endregion
                    break;
                }
            }
            pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //是否显示进度条,加载让它显示
            SetCheckState.CheckShowTips(pAppForm, "重复点检查完成!");
            _AppHk.CurrentThread = null;                                                                     //线程使用完置空

            pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });
            SetCheckState.Message(pAppForm, "提示", "重复点检查完成!");
            //选中检查出错列表
            ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
        }