コード例 #1
0
        /// <summary>
        /// 在数据集中构建拓扑(GP方法)
        /// </summary>
        /// <param name="IN_TopoName">要生成拓扑的名称</param>
        /// <param name="IN_Tolerance">拓扑容差,可选,默认0.001</param>
        public void PUB_TopoBuildWithGP(string IN_TopoName, double IN_Tolerance = 0.001)
        {
            IWorkspace         FeatureWorkSpace = FeatureDataset_Main.Workspace;
            ITopologyWorkspace TopoWorkSpace    = FeatureWorkSpace as ITopologyWorkspace;

            try//若不存在同名拓扑则添加
            {
                Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
                MessageBox.Show("已存在该拓扑,无法添加!");
            }
            catch
            {
                CreateTopology Topotool = new CreateTopology();//拓扑GP工具
                Topotool.in_dataset           = FeatureDataset_Main;;
                Topotool.out_name             = IN_TopoName;
                Topotool.in_cluster_tolerance = IN_Tolerance;
                try
                {
                    GP_Tool.Execute(Topotool, null);
                    Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
                }
                catch (COMException comExc)
                {
                    MessageBox.Show(String.Format("拓扑创建出错: {0} 描述: {1}", comExc.ErrorCode, comExc.Message));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 在数据集中构建拓扑(GP方法)
        /// </summary>
        /// <param name="IN_TopoName">要生成拓扑的名称</param>
        /// <param name="IN_Tolerance">拓扑容差,可选,默认0.001</param>
        public void PUB_TopoBuildWithGP(string IN_TopoName, double IN_Tolerance = 0.001)
        {
            TP_topoName = IN_TopoName;
            IWorkspace         FeatureWorkSpace = FeatureDataset_Main.Workspace;
            ITopologyWorkspace TopoWorkSpace    = FeatureWorkSpace as ITopologyWorkspace;

            try//若不存在同名拓扑则添加
            {
                Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
                CommonClass common = new CommonClass();
                common.DeleteTopolgyFromGISDB(Topology);
                DeleteFeature(TP_topoName);
            }
            catch
            {
            }
            CreateTopology Topotool = new CreateTopology();//拓扑GP工具

            Topotool.in_dataset           = FeatureDataset_Main;;
            Topotool.out_name             = IN_TopoName;
            Topotool.in_cluster_tolerance = IN_Tolerance;
            try
            {
                GP_Tool.Execute(Topotool, null);
                Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
            }
            catch (COMException comExc)
            {
                MessageBox.Show(String.Format("拓扑创建出错: {0} 描述: {1}", comExc.ErrorCode, comExc.Message));
            }
        }
コード例 #3
0
ファイル: TopoOperAPI.cs プロジェクト: zj8487/HyDM
        /// <summary>
        ///  获取子库中所有的拓扑图层
        /// </summary>
        /// <param name="axMapControl"></param>
        /// <param name="strSonPath"></param>
        /// <param name="ipSonFWS"></param>
        /// <param name="ipDataset"></param>
        /// <returns></returns>
        public static bool GetFcTopoNameInSon(AxMapControl axMapControl, IFeatureWorkspace ipSonFWS,
                                              IFeatureDataset ipDataset)
        {
            ITopologyWorkspace     ipTopologyWS        = null;
            IFeatureClassContainer pFeatClassContainer = null;

            try
            {
                ipTopologyWS = (ITopologyWorkspace)ipSonFWS;

                if (ipDataset == null)
                {
                    return(false);
                }

                pFeatClassContainer = (IFeatureClassContainer)ipDataset;

                List <string> arrayTopoLayers = new List <string>();

                arrayTopoLayers.Add(COMMONCONST.Topology_Name);

                //-------------------------------获取拓扑图层,并在地图上显示------------------------------------//
                AddTopoLayer(ref axMapControl, arrayTopoLayers[0], ipTopologyWS, pFeatClassContainer, ipDataset);
            }
            catch (Exception ex)
            {
                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(ex.Message);
                return(false);
            }
            finally
            {
                //释放接口
                if (pFeatClassContainer != null)
                {
                    Marshal.ReleaseComObject(pFeatClassContainer);
                    pFeatClassContainer = null;
                }

                if (ipTopologyWS != null)
                {
                    Marshal.ReleaseComObject(ipTopologyWS);
                    ipTopologyWS = null;
                }
            }
            return(true);
            //------------------------------------------------------------------------------------------------//
        }
コード例 #4
0
        public static ITopology OpenTopology(IWorkspace TheWorkspace, string TopologyName)
        {
            ITopologyWorkspace topoWorkspace = (ITopologyWorkspace)TheWorkspace;

            return(topoWorkspace.OpenTopology(commonFunctions.QualifyClassName(TheWorkspace, TopologyName)));
        }
コード例 #5
0
ファイル: TopoOperAPI.cs プロジェクト: hy1314200/HyDM
        //加载拓扑图层
        public static void AddTopoLayer(ref AxMapControl pMapCtrl, string strTopoLayerName, ITopologyWorkspace ipTopologyWS,IFeatureClassContainer ipFeatClassContainer, IFeatureDataset ipFeatDataset)
        {
            int nOriginClassID, nDestClassID;

            ITopology ipTopology;

            //打开数据集
            //ITopologyContainer ipTopoContainer = (ITopologyContainer)ipFeatDataset;

            IWorkspace2 pWorkspace = (IWorkspace2)ipFeatDataset.Workspace;

            if (pWorkspace.get_NameExists(esriDatasetType.esriDTTopology, strTopoLayerName))
            {
                ipTopology = ipTopologyWS.OpenTopology(strTopoLayerName);

                if (ipTopology == null)
                {
                    return;
                }

                ITopologyLayer ipTopologyLayer = new TopologyLayerClass();
                ipTopologyLayer.Topology = ipTopology;

                ILegendInfo legendInfo = (ILegendInfo)ipTopologyLayer;

                for (int i = 0; i < legendInfo.LegendGroupCount; i++)
                {
                    ILegendGroup legendgroup = legendInfo.get_LegendGroup(i);

                    ILegendClass legendclass = legendgroup.get_Class(0);

                    switch (legendgroup.Heading)
                    {
                        case "Area Errors":
                            {
                                legendgroup.Heading = "";
                                legendclass.Label = "面状错误";
                                legendclass.Description = "面状错误";
                                break;
                            }
                        case "Line Errors":
                            {
                                legendgroup.Heading = "";
                                legendclass.Label = "线状错误";
                                legendclass.Description = "线状错误";
                                break;
                            }
                        case "Point Errors":
                            {
                                legendgroup.Heading = "";
                                legendclass.Label = "点状错误";
                                legendclass.Description = "点状错误";
                                break;
                            }
                    }

                }

                ILayer ipLayer = (ILayer)ipTopologyLayer;
                ipLayer.Name = strTopoLayerName; //将拓扑检查合并后,将拓扑图层名指定为“拓扑错误”后,采用此方法命名  hehy20080724

                /*  将拓扑检查合并后,将拓扑图层名指定为“拓扑错误”后,注销以下代码 hehy20080724
                ///////////////////////////////////////////////////
                //得到拓扑层相对应的规则名称
                CModelSchema pModelSchema = new CModelSchema();
                string strRuleName = pModelSchema.GetRuleNameByTopoLayerName(m_pTask.pSchema, strTopoLayerName);
                //////////////////////////////////////////////////
                if (strRuleName.Length == 0)
                {
                    ipLayer.Name = strTopoLayerName;
                }
                else
                {
                    ipLayer.Name = strRuleName;
                }
                */
                //把拓扑图层加载到map控件中
                //pMapCtrl.AddLayer(ipLayer, pMapCtrl.LayerCount);
                pMapCtrl.Map.AddLayer(ipLayer);
                //pMapCtrl.ActiveView.Extent = ipLayer.AreaOfInterest;
            }
        }
コード例 #6
0
ファイル: TopoOperAPI.cs プロジェクト: zj8487/HyDM
        //加载拓扑图层
        public static void AddTopoLayer(ref AxMapControl pMapCtrl, string strTopoLayerName, ITopologyWorkspace ipTopologyWS, IFeatureClassContainer ipFeatClassContainer, IFeatureDataset ipFeatDataset)
        {
            int nOriginClassID, nDestClassID;

            ITopology ipTopology;

            //打开数据集
            //ITopologyContainer ipTopoContainer = (ITopologyContainer)ipFeatDataset;

            IWorkspace2 pWorkspace = (IWorkspace2)ipFeatDataset.Workspace;

            if (pWorkspace.get_NameExists(esriDatasetType.esriDTTopology, strTopoLayerName))
            {
                ipTopology = ipTopologyWS.OpenTopology(strTopoLayerName);

                if (ipTopology == null)
                {
                    return;
                }

                ITopologyLayer ipTopologyLayer = new TopologyLayerClass();
                ipTopologyLayer.Topology = ipTopology;



                ILegendInfo legendInfo = (ILegendInfo)ipTopologyLayer;

                for (int i = 0; i < legendInfo.LegendGroupCount; i++)
                {
                    ILegendGroup legendgroup = legendInfo.get_LegendGroup(i);

                    ILegendClass legendclass = legendgroup.get_Class(0);

                    switch (legendgroup.Heading)
                    {
                    case "Area Errors":
                    {
                        legendgroup.Heading     = "";
                        legendclass.Label       = "面状错误";
                        legendclass.Description = "面状错误";
                        break;
                    }

                    case "Line Errors":
                    {
                        legendgroup.Heading     = "";
                        legendclass.Label       = "线状错误";
                        legendclass.Description = "线状错误";
                        break;
                    }

                    case "Point Errors":
                    {
                        legendgroup.Heading     = "";
                        legendclass.Label       = "点状错误";
                        legendclass.Description = "点状错误";
                        break;
                    }
                    }
                }


                ILayer ipLayer = (ILayer)ipTopologyLayer;
                ipLayer.Name = strTopoLayerName; //将拓扑检查合并后,将拓扑图层名指定为“拓扑错误”后,采用此方法命名  hehy20080724

                /*  将拓扑检查合并后,将拓扑图层名指定为“拓扑错误”后,注销以下代码 hehy20080724
                 * ///////////////////////////////////////////////////
                 * //得到拓扑层相对应的规则名称
                 * CModelSchema pModelSchema = new CModelSchema();
                 * string strRuleName = pModelSchema.GetRuleNameByTopoLayerName(m_pTask.pSchema, strTopoLayerName);
                 * //////////////////////////////////////////////////
                 * if (strRuleName.Length == 0)
                 * {
                 *  ipLayer.Name = strTopoLayerName;
                 * }
                 * else
                 * {
                 *  ipLayer.Name = strRuleName;
                 * }
                 */
                //把拓扑图层加载到map控件中
                //pMapCtrl.AddLayer(ipLayer, pMapCtrl.LayerCount);
                pMapCtrl.Map.AddLayer(ipLayer);
                //pMapCtrl.ActiveView.Extent = ipLayer.AreaOfInterest;
            }
        }