/// <summary>
        /// 线重复数字化检查主函数
        /// </summary>
        /// <param name="_AppHk"></param>
        private void ExcuteLineDigitalDuplicateCheck(Plugin.Application.IAppGISRef _AppHk)
        {
            #region 取得进度条对象
            Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;
            //选中数据处理树图项
            DevComponents.DotNetBar.PanelDockContainer PanelTip = _AppHk.DataTree.Parent as DevComponents.DotNetBar.PanelDockContainer;
            if (PanelTip != null)
            {
                PanelTip.DockContainerItem.Selected = true;
            }
            //取得进度条对象
            try
            {
                System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(Line_redo);
                System.Threading.Thread thread = new System.Threading.Thread(start);
                _AppHk.CurrentThread = thread;
                thread.Start(pAppForm);
            }
            catch (Exception ex)
            {
                if (_AppHk.CurrentThread != null)
                {
                    _AppHk.CurrentThread = null;
                }
                SetCheckState.Message(pAppForm, "错误", ex.ToString());
                return;
            }

            #endregion
        }
Beispiel #2
0
        /// <summary>
        /// 检查开启入口
        /// </summary>
        public override void OnClick()
        {
            SetCheckState.pT                = null;
            SetCheckState.Geodatabase       = null; //设置一个集合
            SetCheckState.pRuleCont         = null; //一个拓扑规则检查的集合容器
            SetCheckState.CheckDataBaseName = "";
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }
            base._Checked = true;
            //高亮显示处理结果栏
            DevComponents.DotNetBar.PanelDockContainer PanelTip = _AppHk.DataTree.Parent as DevComponents.DotNetBar.PanelDockContainer;
            PanelTip.DockContainerItem.Selected = true;
            Overridfunction._AppHk = _AppHk;
            int ListCount = list.Count;

            if (ListCount > 0)
            {
                if (ListCount > 1)
                {
                    frmCheckDataBase ShowCheck = new frmCheckDataBase(list);
                    ShowCheck.ShowDialog();
                }
                else if (ListCount == 1)
                {
                    SetCheckState.CheckDataBaseName = list[0].ToString();
                }
                if (SetCheckState.CheckDataBaseName == "")
                {
                    base._Checked = false;
                    return;
                }
                SetCheckTopo();                  //设置拓扑
                OpenState = true;
                SetCheckState.CheckState = true; //如果加载的数据符合我们要检查的数据要求,我们就改变状态
            }
            else
            {
                SetCheckState.Message(pAppFormRef, "提示", "请加载数据进行检查!");
            }
        }
 /// <summary>
 /// 开始处理数据
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_enter_Click(object sender, EventArgs e)
 {
     if (txt_prj.Text != "" && txt_org.Text != "")
     {
         txt_prj.Visible        = false;
         txt_org.Visible        = false;
         btn_cancel.Visible     = false;
         btn_enter.Visible      = false;
         lab_org.Visible        = false;
         labelX1.Visible        = false;
         btn_org.Visible        = false;
         btn_prj.Visible        = false;
         pic_processbar.Visible = true;
         lab_show.Visible       = true;
         Thread thread = new Thread(CreateFeatureClass);
         thread.Start();
     }
     else
     {
         SetCheckState.Message(_AppHk, "提示", "请选择路径!");
     }
 }
 public override void OnClick()
 {
     Overridfunction.name = "重复点";
     if (_AppHk == null)
     {
         return;
     }
     if (_AppHk.MapControl == null)
     {
         return;
     }
     Plugin.Application.IAppFormRef AppFrom = _AppHk as Plugin.Application.IAppFormRef;
     //选中数据处理树图项
     DevComponents.DotNetBar.PanelDockContainer PanelTip = _AppHk.DataTree.Parent as DevComponents.DotNetBar.PanelDockContainer;
     if (PanelTip != null)
     {
         PanelTip.DockContainerItem.Selected = true;
     }
     //点重复数字化检查主函数
     try
     {
         System.Threading.ParameterizedThreadStart start = new System.Threading.ParameterizedThreadStart(ExcutePointDigitalDuplicateCheck);
         System.Threading.Thread thread = new System.Threading.Thread(start);
         _AppHk.CurrentThread = thread;
         thread.Start(_AppHk as object);
     }
     catch (Exception ex)
     {
         if (_AppHk.CurrentThread != null)
         {
             _AppHk.CurrentThread = null;
         }
         SetCheckState.Message(AppFrom, "错误", ex.ToString());
         return;
     }
 }
Beispiel #5
0
        /// <summary>
        /// 设置检查用到的拓扑
        /// </summary>
        private void SetCheckTopo()
        {
            #region 从MAP上获取其要素操作空间及数据集名称
            string            FeatureDataset_Name = "";    //要素数据集的名字
            IFeatureWorkspace pFeatureWorkspace;           //定义要素操作空间
            ///通过MAP上的图层获取我们所需要的数据集
            ILayer layer   = null;                         //定义用来接收指定组下面的图层
            int    L_count = _AppHk.MapControl.LayerCount; //MAP上总图层数
            if (L_count == 0)
            {
                return;              //当MAP上是空,就返回
            }
            for (int G = 0; G < L_count; G++)
            {
                ILayer temp_layer = _AppHk.MapControl.get_Layer(G);
                //判别是不是组,如果是,就从组中取一个层
                if (temp_layer is IGroupLayer && temp_layer.Name == SetCheckState.CheckDataBaseName)
                {
                    ICompositeLayer grouplayer = temp_layer as ICompositeLayer;//把组图层转成组合图层
                    if (grouplayer.Count == 0)
                    {
                        return;
                    }
                    layer = grouplayer.get_Layer(0);//得到MAP中其中一个层
                    break;
                }
            }
            IFeatureLayer f_layer = layer as IFeatureLayer;
            IFeatureClass cl      = f_layer.FeatureClass;//得到对应的要素类
            if (cl.FeatureDataset == null)
            {
                SetCheckState.Message(pAppFormRef, "提示", "您所操作的数据是离散的,请先做数据预处理!");
                return;
            }
            else
            {
                pFeatureWorkspace   = cl.FeatureDataset.Workspace as IFeatureWorkspace;
                FeatureDataset_Name = cl.FeatureDataset.Name;//得到要素类的数据集名称
            }
            #endregion
            IFeatureDataset pfd = pFeatureWorkspace.OpenFeatureDataset(FeatureDataset_Name);//打开一个DATASET数据集

            IGeoDataset pGeoDataset = pfd as IGeoDataset;
            if (pGeoDataset != null)
            {
                SetCheckState.Geodatabase = pGeoDataset;
            }
            ITopologyContainer pTc = pfd as ITopologyContainer;//转成创建拓扑需要的对应对象接口
            #region 创建拓扑,后面的检查都使用这个拓扑
            if (SetCheckState.pT == null)
            {
                ITopology pT_temp = null;//定义一个临时的拓扑
                try
                {
                    if (SetCheckState.CheckDataBaseName == "更新修编数据" || SetCheckState.CheckDataBaseName == "工作库数据")
                    {
                        pT_temp = pTc.get_TopologyByName("Rule");//查找拓扑
                    }
                    else if (SetCheckState.CheckDataBaseName == "现势库数据")
                    {
                        pT_temp = pTc.get_TopologyByName("Rule1");//查找拓扑
                    }
                    if (pT_temp != null)
                    {
                        SetCheckState.pT        = pT_temp;//如果拓扑已存在,我们就把原先的拓扑赋值给定义的全局拓扑
                        SetCheckState.pRuleCont = SetCheckState.pT as ITopologyRuleContainer;
                    }
                }
                catch
                {
                    if (SetCheckState.CheckDataBaseName == "更新修编数据" || SetCheckState.CheckDataBaseName == "工作库数据")
                    {
                        SetCheckState.pT = pTc.CreateTopology("Rule", pTc.DefaultClusterTolerance, -1, "");//创建了个名叫Rule的拓扑。
                    }
                    else if (SetCheckState.CheckDataBaseName == "现势库数据")
                    {
                        SetCheckState.pT = pTc.CreateTopology("Rule1", pTc.DefaultClusterTolerance, -1, "");//创建了个名叫Rule的拓扑。
                    }
                    SetCheckState.pRuleCont = SetCheckState.pT as ITopologyRuleContainer;
                    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.Search(null, false).NextFeature() == null || pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                {
                                    continue;
                                }
                                SetCheckState.pT.AddClass(pFeatureClass, 5, 1, 1, false);//将要验证的要线素类放入拓扑中。
                                #endregion
                            }
                            break;
                        }
                        #endregion
                    }
                }
            }
            #endregion
        }
        /// <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;
            }
        }
Beispiel #7
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);
        }
Beispiel #8
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;
            }
        }
        /// <summary>
        /// 执行检查
        /// </summary>
        /// <param name="AppHk"></param>
        public void ExcuteCheck(Plugin.Application.IAppGISRef AppHk)
        {
            Plugin.Application.IAppFormRef pAppForm = AppHk as Plugin.Application.IAppFormRef;

            ISchemeProject m_pProject = null;                                  //数据库结构文件对象
            int            m_DBScale  = 0;                                     //默认比例尺
            int            m_DSScale  = 0;                                     //数据集比例尺

            ///从图层上获取所有的要素类
            ///
            IMap CurMap = AppHk.MapControl.Map as IMap;                                //获得当前地图对象

            Dictionary <string, ILayer> pLayerDic = new Dictionary <string, ILayer>(); //记录加载到map上的图层对象

            for (int i = 0; i < CurMap.LayerCount; i++)
            {
                ILayer player = CurMap.get_Layer(i);

                //如果是图层组,则退出不做检查
                if (player is IGroupLayer)
                {
                    ICompositeLayer pComLayer = player as ICompositeLayer;
                    for (int k = 0; k < pComLayer.Count; k++)
                    {
                        ILayer mmLayer = pComLayer.get_Layer(k);
                        if (mmLayer == null)
                        {
                            continue;
                        }
                        IFeatureLayer mmFeaLyer = mmLayer as IFeatureLayer;
                        if (mmFeaLyer == null)
                        {
                            continue;
                        }
                        IDataset mDT      = mmFeaLyer.FeatureClass as IDataset;
                        string   tempName = mDT.Name;
                        if (tempName.Contains("."))
                        {
                            tempName = tempName.Substring(tempName.IndexOf('.') + 1);
                        }
                        if (!pLayerDic.ContainsKey(tempName))
                        {
                            pLayerDic.Add(tempName, mmLayer);
                        }
                    }
                    continue;
                }
                IFeatureLayer pFeatlayer = player as IFeatureLayer;
                if (pFeatlayer == null)
                {
                    continue;
                }
                IDataset pdataset = pFeatlayer.FeatureClass as IDataset;

                string tempNm = pdataset.Name;
                if (tempNm.Contains("."))
                {
                    tempNm = tempNm.Substring(tempNm.IndexOf('.') + 1);
                }
                if (player != null && !pLayerDic.ContainsKey(tempNm))
                {
                    pLayerDic.Add(tempNm, player);
                }
            }


            ///读取配置方案到对象
            ///
            m_pProject = new SchemeProjectClass();                                    //创建实例
            m_pProject.Load(this._DBSchemaDocPath, e_FileType.GO_SCHEMEFILETYPE_MDB); //加载schema文件

            if (m_pProject != null)
            {
                #region 获得比例尺信息
                string   DBScale       = m_pProject.get_MetaDataValue("Scale") as string; //获取比例尺信息(总工程中的默认比例尺)
                string[] DBPScaleArayy = DBScale.Split(':');
                m_DBScale = Convert.ToInt32(DBPScaleArayy[1]);
                #endregion

                IChildItemList pProjects = m_pProject as IChildItemList;
                //获取属性库集合信息
                ISchemeItem    pDBList  = pProjects.get_ItemByName("ATTRDB");
                IChildItemList pDBLists = pDBList as IChildItemList;
                //遍历属性库集合
                long DBNum = pDBLists.GetCount();
                for (int i = 0; i < DBNum; i++)
                {
                    m_DSScale = 0;    //比例尺信息

                    //取得属性库信息
                    ISchemeItem pDB = pDBLists.get_ItemByIndex(i);
                    ///获取数据集的比例尺信息,如果获取失败则,取默认比例尺信息
                    IAttribute pa = pDB.AttributeList.get_AttributeByName("Scale") as IAttribute;
                    if (pa == null)
                    {
                        m_DSScale = m_DBScale;
                    }
                    else
                    {
                        string[] DBScaleArayy = pa.Value.ToString().Split(':');
                        m_DSScale = Convert.ToInt32(DBScaleArayy[1]);
                    }

                    IChildItemList pDBs         = pDB as IChildItemList;
                    string         pDatasetName = pDB.Name;

                    ////遍历属性表
                    int TabNum = pDBs.GetCount();
                    for (int j = 0; j < TabNum; j++)
                    {
                        //获取属性表信息
                        ISchemeItem pTable            = pDBs.get_ItemByIndex(j); //获取属性表对象
                        string      pFeatureClassName = pTable.Name;             //要素类名称

                        ///检查图层是否存在
                        if (!pLayerDic.ContainsKey(pFeatureClassName))
                        {
                            ///触发错误事件
                            this._StructErrorEventArgs.ErrorName        = "要素类缺失";
                            this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中存在,却在当前数据中不存在";
                            this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                            this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                            this.OnProgressStep(AppHk, j + 1, TabNum);
                            continue;
                        }

                        #region 检查要素类类型是否与配置方案一致
                        string pFeatureClassType = pTable.Value as string;   //要素类类型
                        ///检查图层类型是否一致
                        ///
                        ILayer player;

                        bool GetlyrSeccess = pLayerDic.TryGetValue(pFeatureClassName, out player);

                        if (GetlyrSeccess)
                        {
                            IFeatureLayer pFeatureLayer = player as IFeatureLayer;

                            switch (pFeatureClassType)
                            {
                            case "ANNO":
                                if (pFeatureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTAnnotation)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为注记类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            case "POINT":
                                if (pFeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为点要素类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            case "LINE":
                                if (pFeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为线要素类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            case "AREA":
                                if (pFeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为面要素类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            ///触发错误事件
                            this._StructErrorEventArgs.ErrorName        = "获取要素类失败";
                            this._StructErrorEventArgs.ErrDescription   = "获取图层失败";
                            this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                            this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                            this.OnProgressStep(AppHk, j + 1, TabNum);
                            continue;
                        }
                        #endregion

                        //遍历字段
                        IAttributeList pAttrs = pTable.AttributeList;
                        long           FNum   = pAttrs.GetCount();

                        //检查非GIS平台定义的字段
                        IFeatureLayer pChecklyr     = player as IFeatureLayer;
                        IFeatureClass pFeatureClass = pChecklyr.FeatureClass;
                        IFields       fields        = pFeatureClass.Fields;

                        //循环属性表中的字段,添加到arcgis的字段对象中
                        for (int k = 0; k < FNum; k++)
                        {
                            //添加自定义属性字段
                            CheckFields(pAttrs, k, fields, pFeatureClassName, AppHk);
                        }

                        this.OnProgressStep(AppHk, j + 1, TabNum);
                    }
                }
            }
            else
            {
                SetCheckState.Message(pAppForm, "提示", "加载配置方案失败!");
            }
        }
Beispiel #11
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);
        }