コード例 #1
0
        //获取错误信息
        private void PRV_GetError(ITopologyRule IN_TopologyRule)
        {
            if (Topology != null)
            {
                IEnvelope Temp_Envolope = (this.Topology as IGeoDataset).Extent;
                IErrorFeatureContainer Temp_ErrorContainer = Topology as IErrorFeatureContainer;
                //获取所有信息
                IEnumTopologyErrorFeature Temp_EnumErrorFeature = Temp_ErrorContainer.get_ErrorFeatures(((IGeoDataset)FeatureDataset_Main).SpatialReference, IN_TopologyRule, Temp_Envolope, true, true);
                ITopologyErrorFeature     Temp_ErrorFeature     = Temp_EnumErrorFeature.Next();
                while (Temp_ErrorFeature != null)
                {
                    IFeature Temp_Feature = Temp_ErrorFeature as IFeature;
                    string   Temp_ErrorInfo;
                    if (Temp_ErrorFeature.DestinationClassID != 0)//检测是否是双要素规则
                    {
                        Temp_ErrorInfo = Temp_ErrorFeature.OriginOID + "," + Temp_ErrorFeature.DestinationOID;
                    }
                    else
                    {
                        Temp_ErrorInfo = Temp_ErrorFeature.OriginOID.ToString();
                    }
                    LI_AllErrorInfo.Add((PRV_RecorverTopologyRuleType((int)(Temp_ErrorFeature.TopologyRuleType))) + " " + Temp_ErrorInfo);//将错误信息加入List

                    //MessageBox.Show("错误:" + PRV_RecorverTopologyRuleType((int)(Temp_ErrorFeature.TopologyRuleType)) + "\r\n错误ID:" + Temp_ErrorInfo);
                    Temp_ErrorFeature = Temp_EnumErrorFeature.Next();
                }
            }
            else
            {
                MessageBox.Show("请先构建拓扑");
            }
        }
コード例 #2
0
        /// <summary>
        /// 导出拓扑错误图形, 在指定要素类中保存扑错误图形
        /// </summary>
        /// <param name="workespace"></param>
        /// <param name="topoDatasetName"></param>
        /// <param name="topoName"></param>
        /// <param name="envelope"></param>
        /// <param name="shpFeatureClass"></param>
        /// <returns></returns>
        public static IFeatureClass TopoErrorToNewFeatureClass(this IWorkspace workespace, string topoDatasetName,
                                                               string topoName, IEnvelope envelope, IFeatureClass shpFeatureClass)
        {
            //获得拓扑
            var topology = GetTopologyByName(workespace as IFeatureWorkspace, topoDatasetName, topoName);

            //打开编辑并验证拓扑
            workespace.StartEdit(() => topology.ValidateTopology(envelope));

            IErrorFeatureContainer errorFeatureContainer = (IErrorFeatureContainer)topology;
            ISpatialReference      spatialReference      = ((IGeoDataset)topology).SpatialReference;

            IWorkspace shpWorkspace = (shpFeatureClass as IDataset).Workspace;

            shpWorkspace.StartEdit(() =>
            {
                var topoRules = GetTopologyRules(topology);
                foreach (ITopologyRule rule in topoRules)
                {
                    IEnumTopologyErrorFeature enumTopologyErrorFeature = errorFeatureContainer.get_ErrorFeatures(spatialReference, rule, envelope, true, true);
                    ITopologyErrorFeature topologyErrorFeature         = null;
                    while ((topologyErrorFeature = enumTopologyErrorFeature.Next()) != null)
                    {
                        IFeature errorFeature = shpFeatureClass.CreateFeature();
                        errorFeature.Shape    = (topologyErrorFeature as IFeature).ShapeCopy;
                        errorFeature.Store();
                    }
                }
            });
            return(shpFeatureClass);
        }
コード例 #3
0
        public static void DoExplode(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            ITopologicalOperator shapeCopy =
                (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID)
                .GetFeature(pTopoErrorFeat.OriginOID)
                .ShapeCopy as ITopologicalOperator;

            if (pTopoErrorFeat.TopologyRuleType == esriTopologyRuleType.esriTRTLineNoMultipart)
            {
            }
        }
コード例 #4
0
        public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
        {
            IActiveView focusMap;
            double      mapUnits;

            if (this.bool_0)
            {
                IEnvelope envelope = null;
                if (this.idisplayFeedback_0 != null)
                {
                    envelope = (this.idisplayFeedback_0 as INewEnvelopeFeedback).Stop();
                    if ((envelope.IsEmpty || envelope.Width == 0 ? true : envelope.Height == 0))
                    {
                        focusMap        = this._context.FocusMap as IActiveView;
                        envelope        = this.ipoint_0.Envelope;
                        mapUnits        = Common.ConvertPixelsToMapUnits(focusMap, 8);
                        envelope.Height = mapUnits;
                        envelope.Width  = mapUnits;
                        envelope.CenterAt(this.ipoint_0);
                    }
                }
                else
                {
                    focusMap        = this._context.FocusMap as IActiveView;
                    envelope        = this.ipoint_0.Envelope;
                    mapUnits        = Common.ConvertPixelsToMapUnits(focusMap, 8);
                    envelope.Height = mapUnits;
                    envelope.Width  = mapUnits;
                    envelope.CenterAt(this.ipoint_0);
                }
                envelope.SpatialReference = this._context.FocusMap.SpatialReference;


                IActiveView               activeView              = this._context.FocusMap as IActiveView;
                IErrorFeatureContainer    topology                = CmdSelectTopology.m_TopologyLayer.Topology as IErrorFeatureContainer;
                IGeoDataset               geoDataset              = CmdSelectTopology.m_TopologyLayer.Topology as IGeoDataset;
                ITopologyErrorSelection   mTopologyLayer          = CmdSelectTopology.m_TopologyLayer as ITopologyErrorSelection;
                IEnumTopologyErrorFeature errorFeaturesByRuleType = topology.ErrorFeaturesByRuleType[geoDataset.SpatialReference, esriTopologyRuleType.esriTRTAny, envelope, mTopologyLayer.SelectErrors, mTopologyLayer.SelectExceptions];
                FixTopologyErrorTool.m_pTopoErroeSelection.Clear();
                for (ITopologyErrorFeature i = errorFeaturesByRuleType.Next(); i != null; i = errorFeaturesByRuleType.Next())
                {
                    FixTopologyErrorTool.m_pTopoErroeSelection.Add(new TopologyError(CmdSelectTopology.m_TopologyLayer, i));
                }
                this.method_0();
                activeView.Refresh();
                this.idisplayFeedback_0 = null;
                this.bool_0             = false;
            }
        }
コード例 #5
0
        public override bool Check(ref List <Error> checkResult)
        {
            try
            {
                if (m_TopologylRule == null)
                {
                    SendMessage(enumMessageType.RuleError, "拓扑规则未创建成功");
                    return(false);
                }

                checkResult = new List <Error>();
                IEnumTopologyErrorFeature enErrorFeature = (m_Topology as IErrorFeatureContainer).get_ErrorFeatures((m_Topology.FeatureDataset as IGeoDataset).SpatialReference, this.m_TopologylRule, (m_Topology.FeatureDataset as IGeoDataset).Extent, true, true);
                ITopologyErrorFeature     errFeature     = enErrorFeature.Next();
                while (errFeature != null)
                {
                    TopoError err = new TopoError();
                    err.DefectLevel = this.DefectLevel;
                    err.ErrorType   = enumErrorType.Topology;
                    err.LayerName   = this.m_psRuleParas.arraySeledLayers[0];
                    err.LayerID     = m_TopologylRule.OriginClassID;
                    if (this.m_psRuleParas.arraySeledLayers.Count > 1)
                    {
                        err.ReferLayerName = this.m_psRuleParas.arraySeledLayers[1];
                    }

                    err.ReferLayerID = m_TopologylRule.DestinationClassID;
                    err.RuleType     = (int)m_TopologylRule.TopologyRuleType;
                    err.RuleID       = this.m_InstanceID;
                    err.Description  = this.InstanceName;
                    err.OID          = errFeature.OriginOID;
                    err.ReferOID     = errFeature.DestinationOID.ToString();
                    err.JHLX         = errFeature.ShapeType;

                    checkResult.Add(err);

                    errFeature = enErrorFeature.Next();
                }

                return(true);
            }
            catch (Exception exp)
            {
                SendMessage(enumMessageType.RuleError, "获取拓扑结果失败");
                SendMessage(enumMessageType.OperationalLog, exp.ToString());
                return(false);
            }
        }
コード例 #6
0
        public static void Simply(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeature feature =
                (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID)
                .GetFeature(pTopoErrorFeat.OriginOID);
            ITopologicalOperator shapeCopy = feature.ShapeCopy as ITopologicalOperator;

            switch (pTopoErrorFeat.TopologyRuleType)
            {
            case esriTopologyRuleType.esriTRTLineNoSelfOverlap:
            case esriTopologyRuleType.esriTRTLineNoSelfIntersect:
                shapeCopy.Simplify();
                feature.Shape = shapeCopy as IGeometry;
                feature.Store();
                break;
            }
        }
コード例 #7
0
        public static bool DeleteError(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeatureClass        class2           = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            esriTopologyRuleType topologyRuleType = pTopoErrorFeat.TopologyRuleType;

            if (topologyRuleType != esriTopologyRuleType.esriTRTPointProperlyInsideArea)
            {
                if (topologyRuleType != esriTopologyRuleType.esriTRTPointCoveredByLineEndpoint)
                {
                    return(false);
                }
            }
            else
            {
                class2.GetFeature(pTopoErrorFeat.OriginOID).Delete();
                return(true);
            }
            class2.GetFeature(pTopoErrorFeat.OriginOID).Delete();
            return(true);
        }
コード例 #8
0
        public void Remove(ITopologyErrorFeature itopologyErrorFeature_0)
        {
            int num = 0;

            while (true)
            {
                if (num >= this.ilist_0.Count)
                {
                    break;
                }
                else if ((this.ilist_0[num] as TopologyError).TopologyErrorFeature == itopologyErrorFeature_0)
                {
                    this.ilist_0.RemoveAt(num);
                    break;
                }
                else
                {
                    num++;
                }
            }
        }
コード例 #9
0
        /// <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;
            }
        }
コード例 #10
0
        /// <summary>
        /// 面重叠检查错误列表  同层面检查  chenyafei  添加20101208
        /// </summary>
        /// <param name="pFeaDatset">数据集</param>
        /// <param name="pTopo">拓扑</param>
        /// <param name="pTopoRuleType">拓扑规则</param>
        /// <param name="pOrgFeaClsNameDic">源图层名</param>
        /// <param name="pEnvelop">拓扑验证范围</param>
        /// <param name="pDataGrid">检查结果列表显示</param>
        /// <param name="outError"></param>
        public void GetAreaNoOverlopErrorList(IFeatureDataset pFeaDatset, ITopology pTopo, IEnvelope pEnvelop, DataGridViewX pDataGrid, out Exception outError)
        {
            outError = null;
            try
            {
                IFeatureClass oriFeaCls = null;     //源要素类
                IFeatureClass desFeaCls = null;     //目标要素类

                //依照拓扑规则获取错误要素
                IErrorFeatureContainer pErrorFeaCon = pTopo as IErrorFeatureContainer;
                ITopologyRuleContainer pTopoRuleCon = pTopo as ITopologyRuleContainer;
                IEnumRule pEnumRule = pTopoRuleCon.Rules;
                pEnumRule.Reset();
                ITopologyRule pTopoRule = pEnumRule.Next() as ITopologyRule;
                //遍历拓扑规则
                while (pTopoRule != null)
                {
                    //if (pTopoRule.TopologyRuleType != pTopoRuleType)
                    //{
                    //    pTopoRule = pEnumRule.Next() as ITopologyRule;
                    //    continue;
                    //}
                    IEnumTopologyErrorFeature pEnumErrorFea = null;
                    try
                    {
                        pEnumErrorFea = pErrorFeaCon.get_ErrorFeatures(
                            (pFeaDatset as IGeoDataset).SpatialReference, pTopoRule, pEnvelop, true, false);
                    }
                    catch (Exception ex)
                    {
                        ////*********************************************
                        ////guozheng 2010-12-24 平安夜  added 系统异常日志
                        //if (ModData.SysLog == null) ModData.SysLog = new clsWriteSystemFunctionLog();
                        //ModData.SysLog.Write(ex);
                        ////**********************************************
                        RemoveTopo(pFeaDatset, pFeaDatset.Name, out outError);
                        outError = ex;
                        return;
                    }
                    if (pEnumErrorFea == null)
                    {
                        pTopoRule = pEnumRule.Next() as ITopologyRule;
                        continue;
                    }

                    //进度条初始值
                    //ModData.m_ProgressBarDetail.Minimum = 0;
                    //ModData.m_ProgressBarDetail.Value = 0;
                    //ModData.m_ProgressBarDetail.Maximum = ModOperator.GetErrCount(pEnumErrorFea);
                    int pValue = 0;
                    //Application.DoEvents();

                    pEnumErrorFea = pErrorFeaCon.get_ErrorFeatures(
                        (pFeaDatset as IGeoDataset).SpatialReference, pTopoRule, pEnvelop, true, false);

                    ITopologyErrorFeature pErrorFea = pEnumErrorFea.Next();
                    //遍历错误要素,进行错误输出
                    while (pErrorFea != null)
                    {
                        double   pMapx        = 0;                            //错误定位点x
                        double   pMapy        = 0;                            //错误定位点y
                        string   errFeaGeoStr = "";                           //错误几何信息
                        string   errCoorStr   = "";
                        string   pFeaClsName  = "";                           //要素类名称
                        int      desID        = pErrorFea.DestinationOID;     //目标要素ID
                        int      oriID        = pErrorFea.OriginOID;          //源要素类ID
                        IFeature oriFeature   = null;                         //源要素
                        IFeature desFeature   = null;                         //目标要素
                        int      oriFeaClsID  = pErrorFea.OriginClassID;      //源要素类ID
                        int      desFeaClsID  = pErrorFea.DestinationClassID; //目标要素类ID
                        string   errDes       = "";                           //错误描述

                        try
                        {
                            //若要素类为空,则说明是对数据集中的所有的同层面进行重叠检查
                            oriFeaCls = (pTopo as IFeatureClassContainer).get_ClassByID(oriFeaClsID);
                            desFeaCls = oriFeaCls;
                        }
                        catch
                        { }

                        if (oriFeaCls != null && oriID > 0)
                        {
                            oriFeature = oriFeaCls.GetFeature(oriID);
                        }
                        else
                        {
                            //源要素OID
                            oriID = -1;
                        }
                        if (desFeaCls != null && desID > 0)
                        {
                            desFeature = desFeaCls.GetFeature(desID);
                        }
                        else
                        {
                            //目标要素OID
                            desID = -1;
                        }
                        double pMinArea = 0;       //面积最小值
                        double pMaxArea = 0;       //重叠面积最大值
                        pFeaClsName = (oriFeaCls as IDataset).Name;
                        if (pFeaClsName.Contains("."))
                        {
                            pFeaClsName = pFeaClsName.Substring(pFeaClsName.IndexOf('.') + 1);
                        }


                        //获得错误几何信息
                        GetZoomErrFea(pErrorFea as IFeature, out pMapx, out pMapy, out errFeaGeoStr, out errCoorStr);

                        //目标数据库对应到元数据库中的OID
                        int dicDesOID = -1;
                        if (desFeature != null)
                        {
                            int index = desFeature.Fields.FindField(desFeaCls.OIDFieldName);
                            if (index != -1)
                            {
                                if (desFeature.get_Value(index).ToString().Trim() != "")
                                {
                                    dicDesOID = Convert.ToInt32(desFeature.get_Value(index).ToString().Trim());
                                }
                            }
                        }
                        string errType = "";
                        if (pTopoRule.TopologyRuleType == esriTopologyRuleType.esriTRTAreaNoOverlap)
                        {
                            errDes  = "OID为" + oriID + "的小班与OID为" + dicDesOID + "的小班之间有重叠";
                            errType = "面重叠检查";
                        }
                        else if (pTopoRule.TopologyRuleType == esriTopologyRuleType.esriTRTAreaNoGaps)
                        {
                            errDes  = "小班之间有缝隙";
                            errType = "面缝隙检查";
                        }

                        //处理错误结果
                        ProcErrorList(errType, pFeaDatset, pFeaClsName, oriID, pFeaClsName, dicDesOID, pMapx, pMapy, errFeaGeoStr, pDataGrid, errDes, errCoorStr);
                        //ProcErrorList(pFeaDatset, pFeaClsName, oriFeature, pFeaClsName, desID, pDataGrid, EnumCheckType.面重叠检查, pErrType, errDes);

                        //错误数加1
                        //ModData.m_ErrCount++;
                        //m_ErrCount++;
                        //m_LabelRes.Text = "同层面重叠检查错误:" + m_ErrCount + "个";

                        //进度条
                        pValue++;
                        //ModData.m_ProgressBarDetail.Value = pValue;
                        //Application.DoEvents();   //实时处理windows消息

                        pErrorFea = pEnumErrorFea.Next();
                    }

                    pTopoRule = pEnumRule.Next() as ITopologyRule;
                }
            }
            catch (Exception ex)
            {
                ////*********************************************
                ////guozheng 2010-12-24 平安夜  added 系统异常日志
                //if (ModData.SysLog == null) ModData.SysLog = new clsWriteSystemFunctionLog();
                //ModData.SysLog.Write(ex);
                ////**********************************************
                outError = ex;
            }
        }
コード例 #11
0
ファイル: TopologyError.cs プロジェクト: secondii/Yutai
 public TopologyError(ITopologyLayer itopologyLayer_1, ITopologyErrorFeature itopologyErrorFeature_1)
 {
     this.itopologyLayer_0        = itopologyLayer_1;
     this.itopologyErrorFeature_0 = itopologyErrorFeature_1;
 }
コード例 #12
0
        public static IFeature CreateFeature(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeature      feature;
            IRowSubtypes  subtypes;
            IGeometry     shape;
            IPolygon      polygon;
            IFeatureClass class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            IFeatureClass class3 = null;

            if (pTopoErrorFeat.DestinationClassID > 0)
            {
                class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID);
            }
            switch (pTopoErrorFeat.TopologyRuleType)
            {
            case esriTopologyRuleType.esriTRTAreaNoGaps:
                break;

            case esriTopologyRuleType.esriTRTAreaNoOverlap:
            {
                IFeature feature2 = class2.GetFeature(pTopoErrorFeat.OriginOID);
                IFeature feature3 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                shape = (feature2.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                if (!shape.IsEmpty)
                {
                    feature2.Shape = shape;
                    feature2.Store();
                }
                else
                {
                    feature2.Delete();
                }
                shape = (feature3.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                if (shape.IsEmpty)
                {
                    feature3.Delete();
                }
                else
                {
                    feature3.Shape = shape;
                    feature3.Store();
                }
                break;
            }

            case esriTopologyRuleType.esriTRTAreaCoveredByAreaClass:
                feature       = class3.CreateFeature();
                subtypes      = (IRowSubtypes)feature;
                shape         = (pTopoErrorFeat as IFeature).Shape;
                feature.Shape = shape;
                try
                {
                    subtypes.InitDefaultValues();
                }
                catch
                {
                }
                feature.Store();
                return(feature);

            case esriTopologyRuleType.esriTRTAreaAreaCoverEachOther:
                if (pTopoErrorFeat.OriginOID <= 0)
                {
                    feature       = class2.CreateFeature();
                    subtypes      = (IRowSubtypes)feature;
                    shape         = (pTopoErrorFeat as IFeature).Shape;
                    feature.Shape = shape;
                    try
                    {
                        subtypes.InitDefaultValues();
                    }
                    catch
                    {
                    }
                    feature.Store();
                    return(feature);
                }
                feature       = class3.CreateFeature();
                subtypes      = (IRowSubtypes)feature;
                shape         = (pTopoErrorFeat as IFeature).Shape;
                feature.Shape = shape;
                try
                {
                    subtypes.InitDefaultValues();
                }
                catch
                {
                }
                feature.Store();
                return(feature);

            case esriTopologyRuleType.esriTRTAreaCoveredByArea:
                feature       = class3.CreateFeature();
                subtypes      = (IRowSubtypes)feature;
                shape         = (pTopoErrorFeat as IFeature).Shape;
                feature.Shape = shape;
                try
                {
                    subtypes.InitDefaultValues();
                }
                catch
                {
                }
                feature.Store();
                return(feature);

            case esriTopologyRuleType.esriTRTAreaBoundaryCoveredByLine:
                feature =
                    (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID)
                    .CreateFeature();
                subtypes = (IRowSubtypes)feature;
                polygon  = (pTopoErrorFeat as IFeature).Shape as IPolygon;
                shape    = new PolylineClass();
                (shape as IPointCollection).AddPointCollection(polygon as IPointCollection);
                feature.Shape = shape;
                try
                {
                    subtypes.InitDefaultValues();
                }
                catch
                {
                }
                feature.Store();
                return(feature);

            case esriTopologyRuleType.esriTRTLineEndpointCoveredByPoint:
                feature       = class3.CreateFeature();
                feature.Shape = (pTopoErrorFeat as IFeature).Shape;
                feature.Store();
                return(feature);

            case esriTopologyRuleType.esriTRTAreaContainPoint:
                feature =
                    (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID)
                    .CreateFeature();
                subtypes      = (IRowSubtypes)feature;
                polygon       = (pTopoErrorFeat as IFeature).Shape as IPolygon;
                shape         = (polygon as IArea).LabelPoint;
                feature.Shape = shape;
                try
                {
                    subtypes.InitDefaultValues();
                }
                catch
                {
                }
                feature.Store();
                return(feature);

            default:
                return(null);
            }
            if (pTopoErrorFeat.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                shape = new PolygonClass();
                IPolyline shapeCopy = (pTopoErrorFeat as IFeature).ShapeCopy as IPolyline;
                shape.SpatialReference = shapeCopy.SpatialReference;
                object before = Missing.Value;
                for (int i = 0; i < (shapeCopy as ISegmentCollection).SegmentCount; i++)
                {
                    (shape as ISegmentCollection).AddSegment((shapeCopy as ISegmentCollection).get_Segment(i),
                                                             ref before, ref before);
                }
                if (!(shape as IPolygon).IsClosed)
                {
                    (shape as IPolygon).Close();
                }
            }
            else
            {
                shape = (pTopoErrorFeat as IFeature).ShapeCopy;
            }
            feature       = class2.CreateFeature();
            feature.Shape = shape;
            subtypes      = (IRowSubtypes)feature;
            try
            {
                subtypes.InitDefaultValues();
            }
            catch
            {
            }
            feature.Store();
            return(feature);
        }
コード例 #13
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;
            }
        }
コード例 #14
0
        private void PRV_GetErrorFeature()
        {
            foreach (ITopologyRule IN_RuleType in LI_ITopologyRule)
            {
                int tempCount = 0;
                DicTopoError.Add(IN_RuleType.OriginSubtype.ToString(), tempCount);
                IEnvelope Temp_Envolope = (this.Topology as IGeoDataset).Extent;
                IErrorFeatureContainer Temp_ErrorContainer = Topology as IErrorFeatureContainer;
                //获取该种错误所有的错误要素
                IEnumTopologyErrorFeature Temp_EnumErrorFeature = Temp_ErrorContainer.get_ErrorFeatures(((IGeoDataset)FeatureDataset_Main).SpatialReference, IN_RuleType, Temp_Envolope, true, false);
                //提取一个错误要素
                ITopologyErrorFeature Temp_ErrorFeature = Temp_EnumErrorFeature.Next();
                if (Temp_ErrorFeature != null)
                {
                    //作为搭建模型的要素
                    IFeature Temp_MoudleFeature = Temp_ErrorFeature as IFeature;
                    //生成要素类需要CLSID和EXCLSID
                    IFeatureClassDescription Temp_FeatureClassDescription = new FeatureClassDescriptionClass();
                    IObjectClassDescription  Temp_ObjectClassDescription  = (IObjectClassDescription)Temp_FeatureClassDescription;
                    //以模型要素为模板构建一个要素类
                    //FeatureDataset_Main.CreateFeatureClass(TP_topoName, Temp_MoudleFeature.Fields, Temp_ObjectClassDescription.InstanceCLSID, Temp_ObjectClassDescription.ClassExtensionCLSID, Temp_MoudleFeature.FeatureType, "Shape", null);
                    //打开生成的目标要素类并加入集合留待输出时使用
                    IFeatureClass Temp_TargetFeatureClass;
                    string        ErrorFeatureName = TP_topoName + "_" + Temp_ErrorFeature.ShapeType.ToString();
                    try
                    {
                        Temp_TargetFeatureClass = (FeatureDataset_Main.Workspace as IFeatureWorkspace).OpenFeatureClass(ErrorFeatureName);
                    }
                    catch
                    {
                        FeatureDataset_Main.CreateFeatureClass(ErrorFeatureName, Temp_MoudleFeature.Fields, Temp_ObjectClassDescription.InstanceCLSID, Temp_ObjectClassDescription.ClassExtensionCLSID, Temp_MoudleFeature.FeatureType, "Shape", null);
                        Temp_TargetFeatureClass = (FeatureDataset_Main.Workspace as IFeatureWorkspace).OpenFeatureClass(ErrorFeatureName);
                    }
                    LI_TopoErrorFeatureClass.Add(Temp_TargetFeatureClass);
                    //将所有错误要素添加进目标要素类
                    IWorkspaceEdit Temp_WorkspaceEdit = (IWorkspaceEdit)FeatureDataset_Main.Workspace;
                    Temp_WorkspaceEdit.StartEditing(true);
                    Temp_WorkspaceEdit.StartEditOperation();
                    IFeatureBuffer Temp_FeatureBuffer = Temp_TargetFeatureClass.CreateFeatureBuffer();

                    //在目标要素类中插入所有错误要素
                    IFeatureCursor featureCursor = Temp_TargetFeatureClass.Insert(false);
                    while (Temp_ErrorFeature != null)
                    {
                        IFeature Temp_Feature = Temp_ErrorFeature as IFeature;
                        //给目标要素附属性
                        Temp_FeatureBuffer.set_Value(1, Temp_ErrorFeature.OriginClassID);
                        Temp_FeatureBuffer.set_Value(2, Temp_ErrorFeature.OriginOID);
                        Temp_FeatureBuffer.set_Value(3, Temp_ErrorFeature.DestinationClassID);
                        Temp_FeatureBuffer.set_Value(4, Temp_ErrorFeature.DestinationOID);
                        Temp_FeatureBuffer.set_Value(5, Temp_ErrorFeature.TopologyRuleType);
                        Temp_FeatureBuffer.set_Value(8, Temp_ErrorFeature.IsException);
                        Temp_FeatureBuffer.Shape = Temp_Feature.Shape;
                        if (this.DicTopoData.ContainsKey(IN_RuleType.OriginSubtype.ToString()))
                        {
                            if (IN_RuleType.Name == "面要素之间无空隙")
                            {
                                IArea pArea = (IArea)Temp_Feature.Shape.Envelope;
                                if (pArea.Area < System.Convert.ToDouble(this.DicTopoData[IN_RuleType.OriginSubtype.ToString()]))
                                {
                                    tempCount++;
                                    DicTopoError[IN_RuleType.OriginSubtype.ToString()] = tempCount;
                                    object featureOID = featureCursor.InsertFeature(Temp_FeatureBuffer);
                                    featureCursor.Flush();//保存要素
                                }
                            }
                        }
                        else
                        {
                            tempCount++;
                            DicTopoError[IN_RuleType.OriginSubtype.ToString()] = tempCount;
                            object featureOID = featureCursor.InsertFeature(Temp_FeatureBuffer);
                            featureCursor.Flush();//保存要素
                        }
                        Temp_ErrorFeature = Temp_EnumErrorFeature.Next();
                    }
                    Temp_WorkspaceEdit.StopEditOperation();
                    Temp_WorkspaceEdit.StopEditing(true);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
                }
            }
        }
コード例 #15
0
        private void method_0()
        {
            this.ipopuMenuWrap_0.Clear();
            this.ipopuMenuWrap_0.AddItem("TopologyError_ZoomTo", false);
            this.ipopuMenuWrap_0.AddItem("TopologyError_PanTo", false);
            this.ipopuMenuWrap_0.AddItem("TopologyError_SelectFeature", false);
            this.ipopuMenuWrap_0.AddItem("ShowTopoRuleDescript", true);
            if (FixTopologyErrorTool.m_pTopoErroeSelection.Count != 0)
            {
                ITopologyErrorFeature topologyErrorFeature = FixTopologyErrorTool.m_pTopoErroeSelection[0].TopologyErrorFeature;
                esriTopologyRuleType  topologyRuleType     = topologyErrorFeature.TopologyRuleType;
                bool flag = true;
                int  num  = 1;
                while (true)
                {
                    if (num >= FixTopologyErrorTool.m_pTopoErroeSelection.Count)
                    {
                        break;
                    }
                    else if (FixTopologyErrorTool.m_pTopoErroeSelection[num].TopologyErrorFeature.TopologyRuleType != topologyRuleType)
                    {
                        flag = false;
                        break;
                    }
                    else
                    {
                        num++;
                    }
                }
                if (flag)
                {
                    esriTopologyRuleType _esriTopologyRuleType = topologyRuleType;
                    switch (_esriTopologyRuleType)
                    {
                    case esriTopologyRuleType.esriTRTAreaNoGaps:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_CreateFeature", true);
                        break;
                    }

                    case (esriTopologyRuleType)2:
                    case (esriTopologyRuleType)6:
                    case esriTopologyRuleType.esriTRTAreaNoGaps | esriTopologyRuleType.esriTRTAreaNoOverlapArea:
                    case esriTopologyRuleType.esriTRTLineInsideArea:
                    case esriTopologyRuleType.esriTRTAreaCoveredByAreaClass | esriTopologyRuleType.esriTRTAreaNoOverlapArea:
                    case esriTopologyRuleType.esriTRTPointCoveredByAreaBoundary:
                    case esriTopologyRuleType.esriTRTAreaCoveredByAreaClass | esriTopologyRuleType.esriTRTAreaNoOverlapArea | esriTopologyRuleType.esriTRTLineCoveredByAreaBoundary:
                    case esriTopologyRuleType.esriTRTAreaContainOnePoint:
                    case esriTopologyRuleType.esriTRTAreaNoGaps | esriTopologyRuleType.esriTRTAreaContainOnePoint:
                    case (esriTopologyRuleType)18:
                    {
                        break;
                    }

                    case esriTopologyRuleType.esriTRTAreaNoOverlap:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                        if (FixTopologyErrorTool.m_pTopoErroeSelection.Count == 1)
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_Merge", false);
                        }
                        this.ipopuMenuWrap_0.AddItem("TopologyError_CreateFeature", false);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTAreaCoveredByAreaClass:
                    case esriTopologyRuleType.esriTRTAreaAreaCoverEachOther:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                        this.ipopuMenuWrap_0.AddItem("TopologyError_CreateFeature", false);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTAreaCoveredByArea:
                    {
Label1:
                        this.ipopuMenuWrap_0.AddItem("TopologyError_CreateFeature", true);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTAreaNoOverlapArea:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                        if (FixTopologyErrorTool.m_pTopoErroeSelection.Count != 1)
                        {
                            break;
                        }
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Merge", false);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTLineCoveredByAreaBoundary:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTPointProperlyInsideArea:
                    {
Label0:
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Delete", true);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTLineNoOverlap:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTLineNoIntersection:
                    {
Label2:
                        if (FixTopologyErrorTool.m_pTopoErroeSelection.Count <= 0)
                        {
                            break;
                        }
                        topologyErrorFeature = FixTopologyErrorTool.m_pTopoErroeSelection[0].TopologyErrorFeature;
                        esriGeometryType shapeType = topologyErrorFeature.ShapeType;
                        bool             flag1     = true;
                        num = 1;
                        while (true)
                        {
                            if (num >= FixTopologyErrorTool.m_pTopoErroeSelection.Count)
                            {
                                break;
                            }
                            else if (FixTopologyErrorTool.m_pTopoErroeSelection[num].TopologyErrorFeature.ShapeType != shapeType)
                            {
                                flag1 = false;
                                break;
                            }
                            else
                            {
                                num++;
                            }
                        }
                        if (!flag1)
                        {
                            break;
                        }
                        if (shapeType != esriGeometryType.esriGeometryPolyline)
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_Split", true);
                            break;
                        }
                        else
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                            break;
                        }
                    }

                    case esriTopologyRuleType.esriTRTLineNoDangles:
                    {
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Extend", true);
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Trim", false);
                        break;
                    }

                    case esriTopologyRuleType.esriTRTLineNoPseudos:
                    {
                        if (FixTopologyErrorTool.m_pTopoErroeSelection.Count != 1)
                        {
                            break;
                        }
                        this.ipopuMenuWrap_0.AddItem("TopologyError_Merge", true);
                        break;
                    }

                    default:
                    {
                        switch (_esriTopologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTPointCoveredByLineEndpoint:
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_Delete", true);
                            break;
                        }

                        case esriTopologyRuleType.esriTRTAreaBoundaryCoveredByLine:
                        case esriTopologyRuleType.esriTRTAreaContainPoint:
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_CreateFeature", true);
                            break;
                        }

                        case esriTopologyRuleType.esriTRTLineNoSelfOverlap:
                        case esriTopologyRuleType.esriTRTLineNoSelfIntersect:
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_Simply", true);
                            break;
                        }

                        case esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch:
                        {
                            if (FixTopologyErrorTool.m_pTopoErroeSelection.Count <= 0)
                            {
                                break;
                            }
                            topologyErrorFeature = FixTopologyErrorTool.m_pTopoErroeSelection[0].TopologyErrorFeature;
                            esriGeometryType shapeType = topologyErrorFeature.ShapeType;
                            bool             flag1     = true;
                            num = 1;
                            while (true)
                            {
                                if (num >= FixTopologyErrorTool.m_pTopoErroeSelection.Count)
                                {
                                    break;
                                }
                                else if (FixTopologyErrorTool.m_pTopoErroeSelection[num].TopologyErrorFeature.ShapeType != shapeType)
                                {
                                    flag1 = false;
                                    break;
                                }
                                else
                                {
                                    num++;
                                }
                            }
                            if (!flag1)
                            {
                                break;
                            }
                            if (shapeType != esriGeometryType.esriGeometryPolyline)
                            {
                                this.ipopuMenuWrap_0.AddItem("TopologyError_Split", true);
                                break;
                            }
                            else
                            {
                                this.ipopuMenuWrap_0.AddItem("TopologyError_Subtract", true);
                                break;
                            }
                        }

                        case esriTopologyRuleType.esriTRTLineEndpointCoveredByPoint:
                        {
                            this.ipopuMenuWrap_0.AddItem("TopologyError_CreateFeature", true);
                            break;
                        }
                        }
                        break;
                    }
                    }
                }
                this.ipopuMenuWrap_0.AddItem("PromoteToRuleException", true);
                this.ipopuMenuWrap_0.AddItem("DemoteFromRuleException", false);
            }
        }
コード例 #16
0
        /// <summary>
        /// 面套面处理主函数
        /// </summary>
        /// <param name="_AppHk"></param>
        private void ExcutePolygonOverlapTreat()
        {
            Plugin.Application.IAppFormRef pAppFrm = _AppHk as Plugin.Application.IAppFormRef;

            pAppFrm.MainForm.Invoke(new ShowTips(ShowStatusTips), new object[] { pAppFrm, "正在获取所有面层..." });
            //获取所有面层
            List <ILayer> listLayers = GetCheckLayers(_AppHk.MapControl.Map, "更新修编数据");

            if (listLayers == null)
            {
                return;
            }
            List <ILayer> listCheckLays = new List <ILayer>();

            //遍历更新库体里的所有层
            foreach (ILayer pTempLay in listLayers)
            {
                IFeatureLayer pFeatLay = pTempLay as IFeatureLayer;
                if (pFeatLay == null)
                {
                    continue;
                }
                if (pFeatLay.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    continue;
                }
                //接边针对的是线和面,所以我们操作时只需对线和面层进行即可
                if (pFeatLay.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon)
                {
                    continue;
                }

                listCheckLays.Add(pTempLay);
            }
            if (listCheckLays.Count == 0)
            {
                return;
            }

            //遍历各个面层并与其它面层建立拓扑规则以获取所有存在重叠的最小面
            pAppFrm.MainForm.Invoke(new ShowTips(ShowStatusTips), new object[] { pAppFrm, "正在建立拓扑规则..." });
            Dictionary <ITopologyRule, IFeatureClass> dicTemp = new Dictionary <ITopologyRule, IFeatureClass>();
            ITopologyRuleContainer pTopologyRuleContainer     = SetCheckState.pT as ITopologyRuleContainer;//使用建立好的拓扑

            //遍历我们得出的所有面层并操作
            foreach (ILayer pLay in listCheckLays)
            {
                IFeatureLayer pFeatLay = pLay as IFeatureLayer;
                if (pFeatLay == null)
                {
                    continue;
                }
                ITopologyRule topologyRule = new TopologyRuleClass();                       //实例一个拓扑规则类
                topologyRule.TopologyRuleType  = esriTopologyRuleType.esriTRTAreaNoOverlap; //使用规则的类型(面不相交)
                topologyRule.OriginClassID     = pFeatLay.FeatureClass.FeatureClassID;
                topologyRule.AllOriginSubtypes = true;
                topologyRule.Name = pFeatLay.FeatureClass.AliasName;
                if (pTopologyRuleContainer.get_CanAddRule(topologyRule) == true)//提示拓扑规则是否可以被添加
                {
                    pTopologyRuleContainer.AddRule(topologyRule);
                    dicTemp.Add(topologyRule, pFeatLay.FeatureClass);
                }

                foreach (ILayer pOtherLay in listCheckLays)
                {
                    if (pOtherLay == pLay)
                    {
                        continue;
                    }
                    IFeatureLayer pOtherFeatLay = pOtherLay as IFeatureLayer;
                    if (pOtherFeatLay == null)
                    {
                        continue;
                    }
                    topologyRule = new TopologyRuleClass();
                    topologyRule.TopologyRuleType       = esriTopologyRuleType.esriTRTAreaNoOverlapArea;
                    topologyRule.OriginClassID          = pFeatLay.FeatureClass.FeatureClassID;
                    topologyRule.AllOriginSubtypes      = true;
                    topologyRule.DestinationClassID     = pOtherFeatLay.FeatureClass.FeatureClassID;
                    topologyRule.AllDestinationSubtypes = true;
                    topologyRule.Name = pFeatLay.FeatureClass.AliasName + " AreaNoOverlapArea with " + pOtherFeatLay.FeatureClass.AliasName;
                    if (pTopologyRuleContainer.get_CanAddRule(topologyRule) == true)
                    {
                        pTopologyRuleContainer.AddRule(topologyRule);
                        dicTemp.Add(topologyRule, pFeatLay.FeatureClass);
                    }
                }
            }

            pAppFrm.MainForm.Invoke(new ShowTips(ShowStatusTips), new object[] { pAppFrm, "正在验证拓扑..." });
            ISegmentCollection pLocation = new PolygonClass();                            //使用多边形接口

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

            pAppFrm.MainForm.Invoke(new ShowTips(ShowStatusTips), new object[] { pAppFrm, "正在分析获取要处理的要素..." });
            pAppFrm.MainForm.Invoke(new ShowProgress(ShowProgressBar), new object[] { pAppFrm, true });
            pAppFrm.MainForm.Invoke(new ChangeProgress(ChangeProgressBar), new object[] { pAppFrm.ProgressBar, 0, dicTemp.Count, 0 });
            //获取所有存在重叠的最小面
            Dictionary <IFeature, IFeatureClass> dicCheckFeats = new Dictionary <IFeature, IFeatureClass>();
            IErrorFeatureContainer pErrFeatCon = SetCheckState.pT as IErrorFeatureContainer;
            IEnumRule pEnumRule = pTopologyRuleContainer.Rules;

            pEnumRule.Reset();
            ITopologyRule pTempTopologyRule = pEnumRule.Next() as ITopologyRule;
            int           intcnt            = 0;

            while (pTempTopologyRule != null)
            {
                intcnt++;
                pAppFrm.MainForm.Invoke(new ChangeProgress(ChangeProgressBar), new object[] { pAppFrm.ProgressBar, -1, -1, intcnt });
                if (!(pTempTopologyRule.TopologyRuleType == esriTopologyRuleType.esriTRTAreaNoOverlap || pTempTopologyRule.TopologyRuleType == esriTopologyRuleType.esriTRTAreaNoOverlapArea))
                {
                    continue;
                }
                IEnumTopologyErrorFeature pEnumTopoErrFeat = pErrFeatCon.get_ErrorFeatures(SetCheckState.Geodatabase.SpatialReference, pTempTopologyRule, SetCheckState.Geodatabase.Extent, true, false);
                ITopologyErrorFeature     pTopoErrFeat     = pEnumTopoErrFeat.Next();

                IFeatureClass pOrgFeatCls = null;
                if (dicTemp.ContainsKey(pTempTopologyRule))
                {
                    pOrgFeatCls = dicTemp[pTempTopologyRule];
                }
                if (pOrgFeatCls == null)
                {
                    break;
                }
                IDataset pDatasetTemp = pOrgFeatCls as IDataset;
                while (pTopoErrFeat != null)
                {
                    IFeature orgFeat  = pOrgFeatCls.GetFeature(pTopoErrFeat.OriginOID);
                    bool     bHasFeat = false;
                    foreach (ILayer pLay in listCheckLays)
                    {
                        IFeatureLayer pFeatLay = pLay as IFeatureLayer;
                        if (pFeatLay == null)
                        {
                            continue;
                        }
                        IDataset pDataset = pFeatLay.FeatureClass as IDataset;
                        string   strCon   = "";
                        //排除指定要素
                        if (pDataset.Name == pDatasetTemp.Name)
                        {
                            strCon = "OBJECTID<>" + orgFeat.OID.ToString();
                        }

                        //判断面orgFeat内是否包含有面
                        if (HasFeatureWithInGeometry(pFeatLay.FeatureClass, orgFeat.Shape, strCon) == true)
                        {
                            bHasFeat = true;
                            break;
                        }
                    }

                    if (bHasFeat == false)
                    {
                        dicCheckFeats.Add(orgFeat, pOrgFeatCls);
                    }
                    pTopoErrFeat = pEnumTopoErrFeat.Next();
                }

                pTempTopologyRule = pEnumRule.Next() as ITopologyRule;
            }

            pAppFrm.MainForm.Invoke(new ShowTips(ShowStatusTips), new object[] { pAppFrm, "处理数据中..." });
            pAppFrm.MainForm.Invoke(new ChangeProgress(ChangeProgressBar), new object[] { pAppFrm.ProgressBar, 0, dicCheckFeats.Count, 0 });

            Exception err = null;
            //开启编辑  wjj 20090921
            IDataset       pFeatDataset   = SetCheckState.Geodatabase as IDataset;
            IWorkspaceEdit pWorkspaceEdit = pFeatDataset.Workspace as IWorkspaceEdit;

            if (pWorkspaceEdit.IsBeingEdited() == false)
            {
                pWorkspaceEdit.StartEditing(false);
            }

            //遍历上步所获得到的重叠最小面,分析获取包含该面的所有面并根据面积排序
            intcnt = 0;
            foreach (KeyValuePair <IFeature, IFeatureClass> keyvlue in dicCheckFeats)
            {
                intcnt++;
                pAppFrm.MainForm.Invoke(new ChangeProgress(ChangeProgressBar), new object[] { pAppFrm.ProgressBar, -1, -1, intcnt });
                IFeature pFeat = keyvlue.Key;
                Dictionary <IFeature, IFeatureClass> dicFeats = GetFeaturesByGeometry(pFeat, listCheckLays);
                bool bDel = false;
                if (dicFeats.Count > 0)
                {
                    //从外到内做处理,处理原则分类代码相同则利用小面套空大面并删除小面,不同则小面套空大面
                    IFeature[] pFeatArray = new IFeature[dicFeats.Count];
                    dicFeats.Keys.CopyTo(pFeatArray, 0);
                    for (int i = 0; i < dicFeats.Count - 1; i++)
                    {
                        if (bDel == false)
                        {
                            IFeature pBigFeat = pFeatArray[i];
                            IFeature pLowFeat = pFeatArray[i + 1];

                            //小面掏空大面
                            UpdateFeatureByOverlapArea(dicFeats[pBigFeat], "OBJECTID=" + pBigFeat.OID.ToString(), pLowFeat.Shape, out err);
                            if (pBigFeat.get_Value(pBigFeat.Fields.FindField("CODE")).ToString() == pLowFeat.get_Value(pLowFeat.Fields.FindField("CODE")).ToString())
                            {
                                SysCommon.Gis.ModGisPub.DelFeature(dicFeats[pLowFeat], "OBJECTID=" + pLowFeat.OID.ToString(), out err);
                                bDel = true;
                            }
                            else
                            {
                                bDel = false;
                            }
                        }
                        else
                        {
                            bDel = false;
                        }
                    }


                    IFeature pLastFeat = pFeatArray[dicFeats.Count - 1];
                    //小面掏空大面
                    UpdateFeatureByOverlapArea(dicFeats[pLastFeat], "OBJECTID=" + pLastFeat.OID.ToString(), pFeat.Shape, out err);
                    if (pLastFeat.get_Value(pLastFeat.Fields.FindField("CODE")).ToString() == pFeat.get_Value(pFeat.Fields.FindField("CODE")).ToString())
                    {
                        SysCommon.Gis.ModGisPub.DelFeature(dicCheckFeats[pFeat], "OBJECTID=" + pFeat.OID.ToString(), out err);
                        bDel = true;
                    }
                    else
                    {
                        bDel = false;
                    }
                }
            }

            pEnumRule.Reset();
            pTempTopologyRule = pEnumRule.Next() as ITopologyRule;
            while (pTempTopologyRule != null)
            {
                pTopologyRuleContainer.DeleteRule(pTempTopologyRule);
                pTempTopologyRule = pEnumRule.Next() as ITopologyRule;
            }

            //结束编辑 wjj 20090921
            if (pWorkspaceEdit.IsBeingEdited() == true)
            {
                pWorkspaceEdit.StopEditing(true);
            }

            _AppHk.CurrentThread = null;
            pAppFrm.MainForm.Invoke(new ShowTips(ShowStatusTips), new object[] { pAppFrm, "" });
            pAppFrm.MainForm.Invoke(new ShowProgress(ShowProgressBar), new object[] { pAppFrm, false });
            pAppFrm.MainForm.Invoke(new ShowForm(ShowErrForm), new object[] { "提示", "处理完毕!" });
        }
コード例 #17
0
        public static void DoSplit(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeatureClass class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            IFeatureClass class3 = null;

            try
            {
                if (pTopoErrorFeat.DestinationClassID != 0)
                {
                    class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID);
                }
            }
            catch
            {
            }
            esriTopologyRuleType topologyRuleType = pTopoErrorFeat.TopologyRuleType;

            if (((topologyRuleType == esriTopologyRuleType.esriTRTLineNoIntersection) ||
                 (topologyRuleType == esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch)) &&
                ((pTopoErrorFeat as IFeature).Shape is IPoint))
            {
                int        num;
                IFeature   feature2;
                IFeature   feature3;
                IFeature   feature   = class2.GetFeature(pTopoErrorFeat.OriginOID);
                IPolycurve shapeCopy = feature.ShapeCopy as IPolycurve;
                IPoint     shape     = (pTopoErrorFeat as IFeature).Shape as IPoint;
                IList      list      = PointSplitLine(shapeCopy, shape);
                for (num = 0; num < list.Count; num++)
                {
                    if (num == 0)
                    {
                        feature.Shape = list[num] as IGeometry;
                        feature.Store();
                    }
                    else
                    {
                        feature2       = RowOperator.CreatRowByRow(feature) as IFeature;
                        feature2.Shape = list[num] as IGeometry;
                    }
                }
                if (class3 == null)
                {
                    feature3 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                }
                else
                {
                    feature3 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                }
                shapeCopy = feature3.ShapeCopy as IPolycurve;
                list      = PointSplitLine(shapeCopy, shape);
                for (num = 0; num < list.Count; num++)
                {
                    if (num == 0)
                    {
                        feature3.Shape = list[num] as IGeometry;
                        feature3.Store();
                    }
                    else
                    {
                        feature2       = RowOperator.CreatRowByRow(feature3) as IFeature;
                        feature2.Shape = list[num] as IGeometry;
                        feature2.Store();
                    }
                }
            }
        }
コード例 #18
0
        public static void Merge(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            frmSelectMergeFeature feature;
            IGeometry             geometry;
            IFeature             feature2;
            IFeature             feature3;
            ITopologicalOperator shapeCopy;
            IFeatureClass        class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            IFeatureClass        class3 = null;

            try
            {
                if (pTopoErrorFeat.DestinationClassID != 0)
                {
                    class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID);
                }
            }
            catch
            {
            }
            string[] strArray = new string[2];
            switch (pTopoErrorFeat.TopologyRuleType)
            {
            case esriTopologyRuleType.esriTRTAreaNoOverlap:
                strArray[0] = class2.AliasName + "-" + pTopoErrorFeat.OriginOID;
                strArray[1] = class2.AliasName + "-" + pTopoErrorFeat.DestinationOID;
                feature     = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray
                };
                if (feature.ShowDialog() == DialogResult.OK)
                {
                    feature2 = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature3 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature.SelectedIndex == 0)
                    {
                        shapeCopy      = feature2.ShapeCopy as ITopologicalOperator;
                        geometry       = shapeCopy.Union(feature3.Shape);
                        feature2.Shape = geometry;
                        feature2.Store();
                        feature3.Delete();
                    }
                    else
                    {
                        shapeCopy      = feature3.ShapeCopy as ITopologicalOperator;
                        geometry       = shapeCopy.Union(feature2.Shape);
                        feature3.Shape = geometry;
                        feature3.Store();
                        feature2.Delete();
                    }
                }
                break;

            case esriTopologyRuleType.esriTRTAreaNoOverlapArea:
                strArray[0] = class2.AliasName + "-" + pTopoErrorFeat.OriginOID;
                strArray[1] = class3.AliasName + "-" + pTopoErrorFeat.DestinationOID;
                feature     = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray
                };
                if (feature.ShowDialog() == DialogResult.OK)
                {
                    feature2 = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature3 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature.SelectedIndex == 0)
                    {
                        shapeCopy      = feature2.ShapeCopy as ITopologicalOperator;
                        geometry       = shapeCopy.Union(feature3.Shape);
                        feature2.Shape = geometry;
                        feature2.Store();
                        feature3.Delete();
                    }
                    else
                    {
                        shapeCopy      = feature3.ShapeCopy as ITopologicalOperator;
                        geometry       = shapeCopy.Union(feature2.Shape);
                        feature3.Shape = geometry;
                        feature3.Store();
                        feature2.Delete();
                    }
                }
                break;

            case esriTopologyRuleType.esriTRTLineNoPseudos:
                strArray[0] = class2.AliasName + "-" + pTopoErrorFeat.OriginOID;
                strArray[1] = class3.AliasName + "-" + pTopoErrorFeat.DestinationOID;
                feature     = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray
                };
                if (feature.ShowDialog() == DialogResult.OK)
                {
                    feature2 = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature3 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature.SelectedIndex == 0)
                    {
                        shapeCopy      = feature2.ShapeCopy as ITopologicalOperator;
                        geometry       = shapeCopy.Union(feature3.Shape);
                        feature2.Shape = geometry;
                        feature2.Store();
                        feature3.Delete();
                    }
                    else
                    {
                        geometry       = (feature3.ShapeCopy as ITopologicalOperator).Union(feature2.Shape);
                        feature3.Shape = geometry;
                        feature3.Store();
                        feature2.Delete();
                    }
                }
                break;
            }
        }
コード例 #19
0
        public static void Subtract(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IGeometry geometry;

            string[] strArray;
            frmSelectMergeFeature feature3;
            IFeatureClass         class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            IFeatureClass         class3 = null;

            try
            {
                if (pTopoErrorFeat.DestinationClassID != 0)
                {
                    class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID);
                }
            }
            catch
            {
            }
            IFeature             feature   = null;
            IFeature             feature2  = null;
            ITopologicalOperator shapeCopy = null;

            switch (pTopoErrorFeat.TopologyRuleType)
            {
            case esriTopologyRuleType.esriTRTAreaNoOverlap:
                feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                feature2 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                geometry = (feature.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                if (!geometry.IsEmpty)
                {
                    feature.Shape = geometry;
                    feature.Store();
                    break;
                }
                feature.Delete();
                break;

            case esriTopologyRuleType.esriTRTAreaCoveredByAreaClass:
                feature   = class2.GetFeature(pTopoErrorFeat.OriginOID);
                shapeCopy = feature.ShapeCopy as ITopologicalOperator;
                geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                if (!geometry.IsEmpty)
                {
                    feature.Shape = geometry;
                    feature.Store();
                    return;
                }
                feature.Delete();
                return;

            case esriTopologyRuleType.esriTRTAreaAreaCoverEachOther:
                strArray = new string[]
                {
                    class2.AliasName + "-" + pTopoErrorFeat.OriginOID,
                    class3.AliasName + "-" + pTopoErrorFeat.DestinationOID
                };
                feature3 = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray,
                    Text         = "删除"
                };
                if (feature3.ShowDialog() == DialogResult.OK)
                {
                    feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature2 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature3.SelectedIndex != 0)
                    {
                        shapeCopy = feature2.ShapeCopy as ITopologicalOperator;
                        geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                        if (geometry.IsEmpty)
                        {
                            feature2.Delete();
                        }
                        else
                        {
                            feature2.Shape = geometry;
                            feature2.Store();
                        }
                        return;
                    }
                    shapeCopy = feature.ShapeCopy as ITopologicalOperator;
                    geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                    if (!geometry.IsEmpty)
                    {
                        feature.Shape = geometry;
                        feature.Store();
                        return;
                    }
                    feature.Delete();
                }
                return;

            case ((esriTopologyRuleType)6):
            case (esriTopologyRuleType.esriTRTAreaNoOverlapArea | esriTopologyRuleType.esriTRTAreaNoGaps):
                return;

            case esriTopologyRuleType.esriTRTAreaCoveredByArea:
                if (pTopoErrorFeat.OriginOID <= 0)
                {
                    feature2 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                    geometry =
                        (feature2.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                    if (geometry.IsEmpty)
                    {
                        feature2.Delete();
                    }
                    else
                    {
                        feature2.Shape = geometry;
                        feature2.Store();
                    }
                    return;
                }
                feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                geometry = (feature.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                if (!geometry.IsEmpty)
                {
                    feature.Shape = geometry;
                    feature.Store();
                    return;
                }
                feature.Delete();
                return;

            case esriTopologyRuleType.esriTRTAreaNoOverlapArea:
                feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                feature2 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                geometry = (feature.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                if (!geometry.IsEmpty)
                {
                    feature.Shape = geometry;
                    feature.Store();
                }
                else
                {
                    feature.Delete();
                }
                geometry =
                    (feature2.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                if (geometry.IsEmpty)
                {
                    feature2.Delete();
                }
                else
                {
                    feature2.Shape = geometry;
                    feature2.Store();
                }
                return;

            case esriTopologyRuleType.esriTRTLineCoveredByAreaBoundary:
                feature   = class2.GetFeature(pTopoErrorFeat.OriginOID);
                shapeCopy = feature.ShapeCopy as ITopologicalOperator;
                geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                if (!geometry.IsEmpty)
                {
                    feature.Shape = geometry;
                    feature.Store();
                    return;
                }
                feature.Delete();
                return;

            case esriTopologyRuleType.esriTRTLineNoOverlap:
                strArray = new string[]
                {
                    class2.AliasName + "-" + pTopoErrorFeat.OriginOID,
                    class2.AliasName + "-" + pTopoErrorFeat.DestinationOID
                };
                feature3 = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray
                };
                if (feature3.ShowDialog() == DialogResult.OK)
                {
                    feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature2 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature3.SelectedIndex != 0)
                    {
                        shapeCopy = feature2.ShapeCopy as ITopologicalOperator;
                        geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                        if (geometry.IsEmpty)
                        {
                            feature2.Delete();
                        }
                        else
                        {
                            feature2.Shape = geometry;
                            feature2.Store();
                        }
                        return;
                    }
                    shapeCopy = feature.ShapeCopy as ITopologicalOperator;
                    geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                    if (!geometry.IsEmpty)
                    {
                        feature.Shape = geometry;
                        feature.Store();
                        return;
                    }
                    feature.Delete();
                }
                return;

            case esriTopologyRuleType.esriTRTLineNoIntersection:
                strArray = new string[]
                {
                    class2.AliasName + "-" + pTopoErrorFeat.OriginOID,
                    class2.AliasName + "-" + pTopoErrorFeat.DestinationOID
                };
                feature3 = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray
                };
                if (feature3.ShowDialog() == DialogResult.OK)
                {
                    feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature2 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature3.SelectedIndex != 0)
                    {
                        shapeCopy = feature2.ShapeCopy as ITopologicalOperator;
                        geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                        if (geometry.IsEmpty)
                        {
                            feature2.Delete();
                        }
                        else
                        {
                            feature2.Shape = geometry;
                            feature2.Store();
                        }
                        return;
                    }
                    shapeCopy = feature.ShapeCopy as ITopologicalOperator;
                    geometry  = shapeCopy.Difference((pTopoErrorFeat as IFeature).Shape);
                    if (!geometry.IsEmpty)
                    {
                        feature.Shape = geometry;
                        feature.Store();
                        return;
                    }
                    feature.Delete();
                }
                return;

            case esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch:
                strArray = new string[]
                {
                    class2.AliasName + "-" + pTopoErrorFeat.OriginOID,
                    class2.AliasName + "-" + pTopoErrorFeat.DestinationOID
                };
                feature3 = new frmSelectMergeFeature
                {
                    FeatureInfos = strArray,
                    Text         = "删除"
                };
                if (feature3.ShowDialog() == DialogResult.OK)
                {
                    feature  = class2.GetFeature(pTopoErrorFeat.OriginOID);
                    feature2 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                    if (feature3.SelectedIndex != 0)
                    {
                        geometry =
                            (feature2.ShapeCopy as ITopologicalOperator).Difference(
                                (pTopoErrorFeat as IFeature).Shape);
                        if (geometry.IsEmpty)
                        {
                            feature2.Delete();
                        }
                        else
                        {
                            feature2.Shape = geometry;
                            feature2.Store();
                        }
                        return;
                    }
                    geometry =
                        (feature.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
                    if (geometry.IsEmpty)
                    {
                        feature.Delete();
                    }
                    else
                    {
                        feature.Shape = geometry;
                        feature.Store();
                    }
                }
                return;

            default:
                return;
            }
            geometry = (feature2.ShapeCopy as ITopologicalOperator).Difference((pTopoErrorFeat as IFeature).Shape);
            if (geometry.IsEmpty)
            {
                feature2.Delete();
            }
            else
            {
                feature2.Shape = geometry;
                feature2.Store();
            }
        }
コード例 #20
0
        public static bool Trim(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeatureClass class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            IFeatureClass class3 = null;

            try
            {
                if (pTopoErrorFeat.DestinationClassID != 0)
                {
                    class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID);
                }
            }
            catch
            {
            }
            IFeature feature = null;

            if (pTopoErrorFeat.TopologyRuleType == esriTopologyRuleType.esriTRTLineNoDangles)
            {
                feature = class2.GetFeature(pTopoErrorFeat.OriginOID);
                IPoint             shape    = (pTopoErrorFeat as IFeature).Shape as IPoint;
                IPolyline          polyline = feature.Shape as IPolyline;
                double             num      = CommonHelper.distance(polyline.FromPoint, shape);
                double             num2     = CommonHelper.distance(polyline.ToPoint, shape);
                ISegmentCollection segments = polyline as ISegmentCollection;
                ILine          line         = null;
                IConstructLine line2        = new LineClass();
                if (num < num2)
                {
                    line = segments.get_Segment(0) as ILine;
                }
                else
                {
                    line = segments.get_Segment(segments.SegmentCount - 1) as ILine;
                }
                IPolyline polyline2 = new PolylineClass();
                object    before    = Missing.Value;
                (polyline2 as ISegmentCollection).AddSegment(line as ISegment, ref before, ref before);
                ISpatialFilter filter = new SpatialFilterClass
                {
                    Geometry   = polyline2,
                    SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
                };
                IFeatureCursor       o         = class2.Search(filter, false);
                ITopologicalOperator operator2 = polyline2 as ITopologicalOperator;
                IFeature             feature3  = o.NextFeature();
                bool     flag       = true;
                double   num3       = 0.0;
                ICurve   curve      = null;
                IPoint   splitPoint = null;
                IFeature feature4   = null;
                while (feature3 != null)
                {
                    if (feature3.OID != feature.OID)
                    {
                        double    num4;
                        IGeometry geometry2 = operator2.Intersect(feature3.Shape,
                                                                  esriGeometryDimension.esriGeometry0Dimension);
                        if (geometry2 is IPoint)
                        {
                            num4 = CommonHelper.distance(geometry2 as IPoint, shape);
                            if (flag)
                            {
                                flag       = false;
                                num3       = num4;
                                splitPoint = geometry2 as IPoint;
                                curve      = feature3.Shape as ICurve;
                                feature4   = feature3;
                            }
                            else if (num3 > num4)
                            {
                                num3       = num4;
                                splitPoint = geometry2 as IPoint;
                                curve      = feature3.Shape as ICurve;
                                feature4   = feature3;
                            }
                        }
                        if (geometry2 is IPointCollection)
                        {
                            IPointCollection points = geometry2 as IPointCollection;
                            for (int i = 0; i < points.PointCount; i++)
                            {
                                IPoint point3 = points.get_Point(i);
                                num4 = CommonHelper.distance(point3, shape);
                                if (flag)
                                {
                                    flag       = false;
                                    num3       = num4;
                                    splitPoint = point3;
                                    curve      = feature3.Shape as ICurve;
                                    feature4   = feature3;
                                }
                                else if (num3 > num4)
                                {
                                    num3       = num4;
                                    splitPoint = point3;
                                    curve      = feature3.Shape as ICurve;
                                    feature4   = feature3;
                                }
                            }
                        }
                    }
                    feature3 = o.NextFeature();
                }
                ComReleaser.ReleaseCOMObject(o);
                if (curve != null)
                {
                    bool flag2;
                    int  num6;
                    int  num7;
                    polyline.SplitAtPoint(splitPoint, true, false, out flag2, out num6, out num7);
                    if (num < num2)
                    {
                        if (num6 > 0)
                        {
                            (polyline as IGeometryCollection).RemoveGeometries(0, num6);
                        }
                        if (num7 > 0)
                        {
                            (polyline as ISegmentCollection).RemoveSegments(0, num7, false);
                        }
                    }
                    else
                    {
                        if (num6 > 0)
                        {
                            (polyline as IGeometryCollection).RemoveGeometries(num6 + 1,
                                                                               (polyline as IGeometryCollection).GeometryCount - num6);
                        }
                        if (num7 > 0)
                        {
                            (polyline as ISegmentCollection).RemoveSegments(num7 + 1,
                                                                            (polyline as ISegmentCollection).SegmentCount - num7, false);
                        }
                    }
                    if (polyline.IsEmpty)
                    {
                        feature.Delete();
                    }
                    else
                    {
                        feature.Shape = polyline;
                        feature.Store();
                    }
                    (curve as IPolycurve).SplitAtPoint(splitPoint, true, false, out flag2, out num6, out num7);
                    feature4.Shape = curve;
                    feature4.Store();
                    return(true);
                }
            }
            return(false);
        }
コード例 #21
0
        /// <summary>
        /// 重复线
        /// </summary>
        private void Line_redo(object para)
        {
            Plugin.Application.IAppFormRef pAppForm  = para as Plugin.Application.IAppFormRef;
            System.Data.DataTable          Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示
            Datatable.Columns.Add("重复线", typeof(string));                           //创建一列
            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();

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

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

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

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

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

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

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

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

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

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

                    if (num == Count)
                    {
                        SetCheckState.CheckShowTips(pAppForm, "重复线检查马上完成,请稍后....");
                        break;
                    }
                }
                pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //显示完成隐藏进度条
                pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });             //将窗体控件进行方法的委托,因为得让它成为安全的
                _AppHk.CurrentThread = null;                                                                     //将线程置空
                SetCheckState.CheckShowTips(pAppForm, "重复线检查完成!");
                SetCheckState.Message(pAppForm, "提示", "线重复检查完成!");
                //选中检查出错列表
                ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
                #endregion
            }
            catch (Exception ex)
            {
                _AppHk.CurrentThread = null;//将线程置空
                MessageBox.Show(ex.ToString());
                return;
            }
        }
コード例 #22
0
ファイル: GeometryOverlap.cs プロジェクト: EAWCS1/SUITT
        private ArrayList ProcessFeature(ITopologyErrorFeature test, IDataset source, string subtypeName,
			double maxOverlap, double minOverlap)
        {
            if (test == null)
                return null;

            IFeature theTestFeature = (IFeature)test;
            if (theTestFeature.Shape == null || theTestFeature.Shape.IsEmpty)
                return null;

            if (test.ShapeType != esriGeometryType.esriGeometryPolygon)
                return null;

            ArrayList theReturn = new ArrayList();

            int index = this.FindParameter(ParameterInfo.PARAM_CANDEFER);
            bool canDefer = (bool)((ParameterInfo)this._params[index]).ParamValue;
            index = this.FindParameter(ParameterInfo.PARAM_CANEXCEPT);
            bool canExcept = (bool)((ParameterInfo)this._params[index]).ParamValue;

            IGeometry theGeometry = theTestFeature.ShapeCopy;
            theGeometry.Project(SpatialReferenceHelper.BCAlbersSpatialReference);

            // Is/isn't an error based on the full area of the error
            IArea theArea = (IArea)theGeometry;
            bool isError = (theArea.Area > minOverlap && theArea.Area < maxOverlap);

            if (isError)
            {
                // Severity is based on parts
                IGeometryCollection theGeomColl = (IGeometryCollection)theGeometry;
                for (int i = 0; i < theGeomColl.GeometryCount; i++)
                {
                    IGeometry theGeometryPart = theGeomColl.get_Geometry(i);
                    IArea thePartArea = (IArea)theGeometryPart;

                    if (thePartArea.Area > 0)
                    {
                        IPoint theErrorPoint = this.get_ErrorPoint(theGeometryPart);
                        theErrorPoint.Project(SpatialReferenceHelper.GeographicReference);

                        DataQualityError theError = new DataQualityError(this.Name, canDefer, canExcept);
                        theError.Location = theErrorPoint;

                        if (thePartArea.Area > minOverlap && thePartArea.Area < maxOverlap)
                            theError.Severity = 1;
                        else
                            theError.Severity = 2;

                        theError.Description = "Polygons overlap";

                        ExtendedInfo theInfo = new ExtendedInfo();

                        theInfo.AddProperty("Feature class", source.Name);
                        theInfo.AddProperty("Feature subtype", subtypeName);
                        theInfo.AddProperty("Feature ID #1", test.OriginOID.ToString());
                        theInfo.AddProperty("Feature ID #2", test.DestinationOID.ToString());
                        theInfo.AddProperty("Area", thePartArea.Area.ToString());

                        theError.ExtendedData = theInfo.WriteXML();
                        //this.LogMessage(theError.ExtendedData);
                        theReturn.Add(theError);
                    }
                }
            }

            return theReturn;
        }