コード例 #1
0
        /// <summary>
        /// 从工作空间中获得指定的拓扑
        /// </summary>
        /// <param name="featureWorkspace">要素工作空间</param>
        /// <param name="topoDatasetName">包含拓扑的要素数据集名称</param>
        /// <param name="topoName">拓扑名称</param>
        /// <returns></returns>
        public static ITopology GetTopologyByName(this IFeatureWorkspace featureWorkspace, string topoDatasetName, string topoName)
        {
            IFeatureDataset    featureDataset    = featureWorkspace.OpenFeatureDataset(topoDatasetName);
            ITopologyContainer topologyContainer = (ITopologyContainer)featureDataset;

            return(topologyContainer.get_TopologyByName(topoName));
        }
コード例 #2
0
 public ITopology Create_Topology(IFeatureWorkspace featureWorkspace, string featuredatasetName, string featureClassName, string topologyName)
 {
     try
     {
         //1.---打开拓朴所在的要素数据集,并创建拓朴
         IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset(featuredatasetName);
         if (featureDataset != null)
         {
             ITopologyContainer topologyContainer = (ITopologyContainer)featureDataset;
             ITopology          topology          = topologyContainer.CreateTopology("topo", topologyContainer.DefaultClusterTolerance, -1, ""); //在这个地方报错
             //2.---给拓朴加入要素集
             IFeatureClassContainer featureclassContainer = (IFeatureClassContainer)featureDataset;
             IFeatureClass          featureClass          = featureclassContainer.get_ClassByName(featureClassName);
             topology.AddClass(featureClass, 5, 1, 1, false);  // Parameters: AddClass(IClass, double weight, int xyrank, int zrank, Boolean EventNotificationOnValidate).
             //3.---返回拓朴
             return(topology);
         }
     }
     catch (Exception ex)
     {
         //System.Diagnostics.Debug.WriteLine(ex.ToString());
         MessageBox.Show(ex.ToString());
     }
     return(null);
 }
コード例 #3
0
        internal Topology(Dictionary <int, List <string> > levels, Dictionary <string, DependItem> list, DependItem mashupItem, ITopologyContainer container)
        {
            this.userInput = new UserInput();
            this.boltList  = new Dictionary <string, BoltExcuter>();
            this.container = container;
            this.levelList = new Dictionary <int, List <BoltExcuter> >();
            foreach (var level in levels)
            {
                levelList.Add(level.Key, this.CreateLevel(level.Value, list));
            }

            IInputs mashupInput = null;

            if (levels.Count > 0)
            {
                mashupInput = new InputCollection(mashupItem.Previous, boltList);
            }
            else
            {
                mashupInput = this.userInput;
            }
            var mashup = (IMashup)Activator.CreateInstance(mashupItem.Type);

            if (mashup is MashupDelegate)
            {
                ((MashupDelegate)mashup).SetAction(mashupItem.MashupFunction);
            }

            this.mashupExcuter = new MashupExcuter(mashup, mashupInput);
        }
コード例 #4
0
        //topology code
        public ITopology create_topology(IWorkspace myWSp, string[] FCIndex, string TopologyName)
        {
            IEnumDataset myEDS = myWSp.get_Datasets(esriDatasetType.esriDTFeatureDataset);
            IDataset     myDS  = myEDS.Next();

            if (myDS != null)
            {
                DS_Name = myDS.Name;
                IFeatureDataset myFDS = myDS as IFeatureDataset;

                //IWorkspace myWSp = DS as IWorkspace;

                IFeatureClassContainer myFCContainer = myFDS as IFeatureClassContainer;
                //要素类容器
                ITopologyContainer myTopologyContainer = myFDS as ITopologyContainer;
                ITopology          myTopology          = myTopologyContainer.CreateTopology(TopologyName, myTopologyContainer.DefaultClusterTolerance, -1, "");
                int count = 0;
                while (count < FCIndex.Length)
                {
                    myTopology.AddClass(myFCContainer.get_Class(int.Parse(FCIndex[count])), 5, 1, 1, false);
                    count++;
                }
                return(myTopology);
            }
            else
            {
                MessageBox.Show("Error,your Dataset is not a standar DataSet which can be uesed to created topology!");
                return(null);
            }
        }
コード例 #5
0
        private void Progarm()
        {
            IWorkspace workspace = ArcClass.GetmdbWorkspace(mdbFilePath);

            if (workspace == null)
            {
                return;
            }
            IFeatureDataset featureDataset = ArcClass.GetFeatureDataset(workspace, "WJL");
            ISchemaLock     schemalock     = featureDataset as ISchemaLock;

            try
            {
                schemalock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                ITopologyContainer topologyContainer = featureDataset as ITopologyContainer;
                ITopology          topology          = topologyContainer.CreateTopology("ttt", topologyContainer.DefaultClusterTolerance, -1, "");
                IFeatureClass      featureClass      = ArcClass.GetFeatureClass(workspace, "PARK");

                AddRuleToTopology(topology, esriTopologyRuleType.esriTRTAreaNoOverlap, "NO Block OverLap", featureClass);

                IGeoDataset geoDataset = topology as IGeoDataset;
                IEnvelope   envelop    = geoDataset.Extent;
                ValidateTopology(topology, envelop);
            }catch (COMException)
            {
            }
        }
コード例 #6
0
ファイル: TopologyConfig.cs プロジェクト: chunyi-li/Cola
        internal Topology Build(ITopologyContainer container)
        {
            if (!this.inited)
            {
                this.Init();
                this.inited = true;
            }

            return(new Topology(this.levels, this.boltDependlist, this.mashupItem, container));
        }
コード例 #7
0
        /// <summary>
        /// 获取要素数据集中的所有拓扑
        /// </summary>
        /// <param name="featureDataset">要素数据集</param>
        /// <returns></returns>
        public static List <ITopology> GetAllTopology(this IFeatureDataset featureDataset)
        {
            List <ITopology>   result            = new List <ITopology>();
            ITopologyContainer topologyContainer = (ITopologyContainer)featureDataset;

            for (int i = 0; i < topologyContainer.TopologyCount; i++)
            {
                result.Add(topologyContainer.get_Topology(i));
            }
            return(result);
        }
コード例 #8
0
        /// <summary>
        /// Fetch existing topology from a feature dataset
        /// </summary>
        /// <param name="featureDataset">Feature dataset</param>
        /// <param name="topologyName">Existing topology name</param>
        /// <returns>A topology <see cref="ITopology"/>if found otherwise null</returns>
        private ITopology GetTopologyFromFeatureDataset(IFeatureDataset featureDataset, string topologyName)
        {
            ITopology topology = null;

            ITopologyContainer topologyContainer = (ITopologyContainer)featureDataset;

            // Fetch existing topology by name
            if (topologyContainer.TopologyCount > 0)
            {
                topology = topologyContainer.TopologyByName[topologyName];
            }

            return(topology);
        }
コード例 #9
0
        //加载数据集
        private void button3_Click(object sender, EventArgs e)
        {
            IFeatureWorkspace      pFeaWS         = pWorkspace as IFeatureWorkspace;
            List <IFeatureDataset> FeatureDSList2 = new List <IFeatureDataset>();

            for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
            {
                foreach (IFeatureDataset eachDS in FeatureDSList)
                {
                    if (eachDS.Name == checkedListBox1.CheckedItems[i].ToString())
                    {
                        FeatureDSList2.Add(eachDS);
                    }
                }
            }
            foreach (IFeatureDataset FeaDS2 in FeatureDSList2)
            {
                IEnumDataset pEnumDS = FeaDS2.Subsets;
                IDataset     pFeaDS2;
                while ((pFeaDS2 = pEnumDS.Next()) != null)
                {
                    if (pFeaDS2 is IFeatureClass)
                    {
                        IFeatureLayer pFeaLayer = new FeatureLayer();
                        pFeaLayer.FeatureClass = pFeaWS.OpenFeatureClass(pFeaDS2.Name);
                        pFeaLayer.Name         = pFeaDS2.Name;
                        pMap.AddLayer(pFeaLayer as ILayer);
                    }
                }
                //加载拓扑结果
                ITopologyLayer     pTopolayer;
                ITopology          pTopology;
                ILayer             pLayer;
                ITopologyContainer pTopoContainer = (ITopologyContainer)FeaDS2;
                for (int i = 0; i < pTopoContainer.TopologyCount; i++)
                {
                    pTopolayer          = new TopologyLayerClass();
                    pTopology           = pTopoContainer.Topology[i];
                    pTopolayer.Topology = pTopology;
                    pLayer      = pTopolayer as ILayer;
                    pLayer.Name = FeaDS2.Name + "_拓扑" + i + 1;
                    pMap.AddLayer(pLayer);
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// 在数据集中构建拓扑
        /// </summary>
        /// <param name="IN_TopoName">要生成拓扑的名称</param>
        /// <param name="IN_Tolerance">拓扑容差,可选,默认0.001</param>
        public void PUB_TopoBuild(string IN_TopoName, double IN_Tolerance = 0.001)
        {
            ITopologyContainer topologyContainer = (ITopologyContainer)FeatureDataset_Main;

            try//若不存在同名拓扑则添加
            {
                Topology = topologyContainer.get_TopologyByName(IN_TopoName);
                MessageBox.Show("已存在该拓扑。");
            }
            catch
            {
                try
                {
                    Topology = topologyContainer.CreateTopology(IN_TopoName, IN_Tolerance, -1, "");
                }
                catch (COMException comExc)
                {
                    MessageBox.Show(String.Format("拓扑创建出错: {0} 描述: {1}", comExc.ErrorCode, comExc.Message));
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// 在数据集中构建拓扑
        /// </summary>
        /// <param name="IN_TopoName">要生成拓扑的名称</param>
        /// <param name="IN_Tolerance">拓扑容差,可选,默认0.001</param>
        public void PUB_TopoBuild(string IN_TopoName, double IN_Tolerance = 0.001)
        {
            TP_topoName = IN_TopoName;
            ITopologyContainer topologyContainer = (ITopologyContainer)FeatureDataset_Main;

            try//若不存在同名拓扑则添加
            {
                Topology = topologyContainer.get_TopologyByName(IN_TopoName);
                CommonClass common = new CommonClass();
                common.DeleteTopolgyFromGISDB(Topology);
                DeleteFeature(TP_topoName);
            }
            catch
            {
            }
            try
            {
                Topology = topologyContainer.CreateTopology(IN_TopoName, IN_Tolerance, -1, "");
            }
            catch (COMException comExc)
            {
                MessageBox.Show(String.Format("拓扑创建出错: {0} 描述: {1}", comExc.ErrorCode, comExc.Message));
            }
        }
コード例 #12
0
        public void Beat()
        {
            IWorkspace      workspace      = ArcClass.GetmdbWorkspace(mdbFilePath);
            IFeatureDataset featureDataset = ArcClass.GetFeatureDataset(workspace, "WJL");

            if (featureDataset != null)
            {
                ITopologyContainer     topologyContainer     = featureDataset as ITopologyContainer;
                ITopology              topology              = topologyContainer.CreateTopology("result", topologyContainer.DefaultClusterTolerance, -1, "");
                IFeatureClassContainer featureClassContainer = featureDataset as IFeatureClassContainer;
                IFeatureClass          featureClass          = featureClassContainer.get_ClassByName("Roads");
                topology.AddClass(featureClass, 5, 1, 1, false);
                ITopologyRuleContainer topologyRuleContainer = topology as ITopologyRuleContainer;
                ITopologyRule          topologyRule          = new TopologyRuleClass();
                topologyRule.TopologyRuleType = esriTopologyRuleType.esriTRTLineNoOverlap;
                topologyRule.OriginClassID    = featureClass.ObjectClassID;
                topologyRule.Name             = "Roads No Overlap";

                if (topologyRuleContainer.get_CanAddRule(topologyRule))
                {
                    topologyRuleContainer.AddRule(topologyRule);
                }

                topologyRule = new TopologyRuleClass();
                topologyRule.TopologyRuleType  = esriTopologyRuleType.esriTRTLineNoDangles;
                topologyRule.OriginClassID     = featureClass.ObjectClassID;
                topologyRule.AllOriginSubtypes = true;
                topologyRule.Name = "Roads No Dangles";

                // Add the rule to the Topology
                if (topologyRuleContainer.get_CanAddRule(topologyRule))
                {
                    topologyRuleContainer.AddRule(topologyRule);
                }
            }
        }
コード例 #13
0
ファイル: CheckItemsSet.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 设置检查用到的拓扑
        /// </summary>
        private void SetCheckTopo()
        {
            #region 从MAP上获取其要素操作空间及数据集名称
            string            FeatureDataset_Name = "";    //要素数据集的名字
            IFeatureWorkspace pFeatureWorkspace;           //定义要素操作空间
            ///通过MAP上的图层获取我们所需要的数据集
            ILayer layer   = null;                         //定义用来接收指定组下面的图层
            int    L_count = _AppHk.MapControl.LayerCount; //MAP上总图层数
            if (L_count == 0)
            {
                return;              //当MAP上是空,就返回
            }
            for (int G = 0; G < L_count; G++)
            {
                ILayer temp_layer = _AppHk.MapControl.get_Layer(G);
                //判别是不是组,如果是,就从组中取一个层
                if (temp_layer is IGroupLayer && temp_layer.Name == SetCheckState.CheckDataBaseName)
                {
                    ICompositeLayer grouplayer = temp_layer as ICompositeLayer;//把组图层转成组合图层
                    if (grouplayer.Count == 0)
                    {
                        return;
                    }
                    layer = grouplayer.get_Layer(0);//得到MAP中其中一个层
                    break;
                }
            }
            IFeatureLayer f_layer = layer as IFeatureLayer;
            IFeatureClass cl      = f_layer.FeatureClass;//得到对应的要素类
            if (cl.FeatureDataset == null)
            {
                SetCheckState.Message(pAppFormRef, "提示", "您所操作的数据是离散的,请先做数据预处理!");
                return;
            }
            else
            {
                pFeatureWorkspace   = cl.FeatureDataset.Workspace as IFeatureWorkspace;
                FeatureDataset_Name = cl.FeatureDataset.Name;//得到要素类的数据集名称
            }
            #endregion
            IFeatureDataset pfd = pFeatureWorkspace.OpenFeatureDataset(FeatureDataset_Name);//打开一个DATASET数据集

            IGeoDataset pGeoDataset = pfd as IGeoDataset;
            if (pGeoDataset != null)
            {
                SetCheckState.Geodatabase = pGeoDataset;
            }
            ITopologyContainer pTc = pfd as ITopologyContainer;//转成创建拓扑需要的对应对象接口
            #region 创建拓扑,后面的检查都使用这个拓扑
            if (SetCheckState.pT == null)
            {
                ITopology pT_temp = null;//定义一个临时的拓扑
                try
                {
                    if (SetCheckState.CheckDataBaseName == "更新修编数据" || SetCheckState.CheckDataBaseName == "工作库数据")
                    {
                        pT_temp = pTc.get_TopologyByName("Rule");//查找拓扑
                    }
                    else if (SetCheckState.CheckDataBaseName == "现势库数据")
                    {
                        pT_temp = pTc.get_TopologyByName("Rule1");//查找拓扑
                    }
                    if (pT_temp != null)
                    {
                        SetCheckState.pT        = pT_temp;//如果拓扑已存在,我们就把原先的拓扑赋值给定义的全局拓扑
                        SetCheckState.pRuleCont = SetCheckState.pT as ITopologyRuleContainer;
                    }
                }
                catch
                {
                    if (SetCheckState.CheckDataBaseName == "更新修编数据" || SetCheckState.CheckDataBaseName == "工作库数据")
                    {
                        SetCheckState.pT = pTc.CreateTopology("Rule", pTc.DefaultClusterTolerance, -1, "");//创建了个名叫Rule的拓扑。
                    }
                    else if (SetCheckState.CheckDataBaseName == "现势库数据")
                    {
                        SetCheckState.pT = pTc.CreateTopology("Rule1", pTc.DefaultClusterTolerance, -1, "");//创建了个名叫Rule的拓扑。
                    }
                    SetCheckState.pRuleCont = SetCheckState.pT as ITopologyRuleContainer;
                    for (int l = 0; l < L_count; l++)
                    {
                        ILayer layer_1 = _AppHk.MapControl.get_Layer(l); //通过索引得到对应的层
                        #region                                          //判别是不是组,如果是,就从组中取一个层
                        if (layer_1 is IGroupLayer && layer_1.Name == SetCheckState.CheckDataBaseName)
                        {
                            ICompositeLayer grouplayer_1 = layer_1 as ICompositeLayer;//把组图层转成组合图层
                            int             group_count  = grouplayer_1.Count;
                            if (group_count == 0)
                            {
                                return;
                            }
                            for (int g = 0; g < group_count; g++)
                            {
                                ILayer        layer_temp    = grouplayer_1.get_Layer(g);
                                IFeatureLayer pFeaturelayer = layer_temp as IFeatureLayer;
                                IFeatureClass pFeatureClass = pFeaturelayer.FeatureClass;
                                #region 将所有的要素类加入到拓扑中
                                if (pFeatureClass.Search(null, false).NextFeature() == null || pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                {
                                    continue;
                                }
                                SetCheckState.pT.AddClass(pFeatureClass, 5, 1, 1, false);//将要验证的要线素类放入拓扑中。
                                #endregion
                            }
                            break;
                        }
                        #endregion
                    }
                }
            }
            #endregion
        }
コード例 #14
0
ファイル: Checker.cs プロジェクト: zj8487/HyDM
        private void Init()
        {
            this.m_ErrorCount   = 0;
            this.m_SucceedCount = 0;

            // 验证
            if (this.m_BaseWorkspace == null)
            {
                SendMessage(enumMessageType.Exception, "检查驱动的Base库没有设置,无法继续检查");
                return;
            }
            if (this.m_QueryWorkspace == null || this.m_QueryConnection == null)
            {
                SendMessage(enumMessageType.Exception, "检查驱动的Query库没有设置,无法继续检查");
                return;
            }

            // 结果库
            try
            {
                string strResultDBFile = this.m_ResultPath + "\\" + COMMONCONST.DB_Name_Result;
                System.IO.File.Copy(System.Windows.Forms.Application.StartupPath + "\\template\\report\\result_AutoTmpl.mdb", strResultDBFile, true);
                this.m_ResultConnection = Hy.Common.Utility.Data.AdoDbHelper.GetDbConnection(strResultDBFile);
            }
            catch (Exception exp)
            {
                SendMessage(enumMessageType.Exception, string.Format("创建结果库出错,信息:{0}", exp.Message));
                return;
            }

            // 创建规则实例,赋值,分类

            if (RuleInfos == null || RuleInfos.Count == 0)
            {
                return;
            }

            int count = RuleInfos.Count;

            m_NormalRuleList  = new List <ICheckRule>();
            m_TopoRuleList    = new List <ICheckRule>();
            m_DictRuleAndInfo = new Dictionary <ICheckRule, SchemaRule>();
            for (int i = 0; i < count; i++)
            {
                if (this.RuleInfos[i] == null || this.RuleInfos[i].ruleDllInfo == null)
                {
                    continue;
                }

                RuleInfo ruleInfo = new RuleInfo();// this.RuleInfos[i].ruleDllInfo;
                ruleInfo.ID            = this.RuleInfos[i].arrayRuleParas[0].strInstID;
                ruleInfo.Name          = this.RuleInfos[i].arrayRuleParas[0].strName;
                ruleInfo.Paramters     = this.RuleInfos[i].arrayRuleParas[0].pParas;
                ruleInfo.RuleClassInfo = this.RuleInfos[i].ruleDllInfo;
                ruleInfo.Description   = this.RuleInfos[i].strRemark;

                //if (ruleClassInfo == null)
                //    continue;

                if (ruleInfo.RuleClassInfo == null)
                {
                    SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”无类信息,跳过检查", ruleInfo.Name));
                    continue;
                }

                ICheckRule checkRule = RuleFactory.CreateRuleInstance(ruleInfo.RuleClassInfo.DllName, ruleInfo.RuleClassInfo.ClassName);
                if (checkRule == null)
                {
                    SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”反射未成功,跳过检查", ruleInfo.Name));
                    continue;
                }

                try
                {
                    // 参数设置
                    checkRule.BaseWorkspace    = this.m_BaseWorkspace;
                    checkRule.InstanceName     = ruleInfo.Name;
                    checkRule.InstanceID       = ruleInfo.ID;
                    checkRule.DefectLevel      = DefectHelper.GetRuleDefectLevel(ruleInfo.ID);
                    checkRule.MessageHandler   = this.m_Messager;
                    checkRule.QueryConnection  = this.m_QueryConnection;
                    checkRule.QueryWorkspace   = this.m_QueryWorkspace;
                    checkRule.TopoWorkspace    = this.m_TopoWorkspace;
                    checkRule.ResultConnection = this.m_ResultConnection;
                    checkRule.SchemaID         = this.m_SchemaID;
                    checkRule.SetParamters(ruleInfo.Paramters);

                    if (checkRule.ErrorType == enumErrorType.Topology)
                    {
                        if (m_Topology == null)
                        {
                            try
                            {
                                // 先创建Topo库(空库)和结果库
                                if (System.IO.Directory.Exists(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo))
                                {
                                    System.IO.Directory.Delete(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo, true);
                                }
                                Hy.Common.Utility.Esri.AEAccessFactory.CreateFGDB(this.m_TopoDBPath, COMMONCONST.DB_Name_Topo, ref this.m_TopoWorkspace);
                                if (this.m_TopoWorkspace == null)
                                {
                                    SendMessage(enumMessageType.Exception, "创建拓扑库失败");
                                }

                                // 根据Base库找第一个Geodataset的空间参考,用来创建拓扑库
                                ISpatialReference topoSptatialRef = null;
                                IEnumDataset      enDataset       = this.m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTAny);
                                IDataset          ds = enDataset.Next();
                                while (ds != null)
                                {
                                    if (ds is IGeoDataset)
                                    {
                                        topoSptatialRef = (ds as IGeoDataset).SpatialReference;
                                        break;
                                    }
                                    ds = enDataset.Next();
                                }
                                IFeatureDataset fDataset = (this.m_TopoWorkspace as IFeatureWorkspace).CreateFeatureDataset(COMMONCONST.Dataset_Name, topoSptatialRef);
                                if (fDataset == null)
                                {
                                    SendMessage(enumMessageType.Exception, "创建拓扑库Dataset失败");
                                }

                                ITopologyContainer topoContainer = fDataset as ITopologyContainer;
                                //m_Topology = topoContainer.get_TopologyByName(COMMONCONST.Topology_Name);    // 若已有Topology,则不再创建

                                //if (m_Topology == null)
                                m_Topology = topoContainer.CreateTopology(COMMONCONST.Topology_Name, this.m_TopoTolerance, COMMONCONST.TopoError_MaxCount, "esriConfigurationKeywordTopology");
                            }
                            catch (Exception exp)
                            {
                                SendMessage(enumMessageType.Exception, "创建Topology出错,信息:" + exp.ToString());
                            }
                        }
                        (checkRule as ITopologicalRule).Topology = m_Topology;

                        m_TopoRuleList.Add(checkRule);
                    }
                    else
                    {
                        m_NormalRuleList.Add(checkRule);
                    }
                    //m_RuleList.Add(checkRule);
                    m_DictRuleAndInfo.Add(checkRule, this.RuleInfos[i]);
                }
                catch (Exception ex)
                {
                    SendMessage(enumMessageType.Exception, "初始化规则失败,信息:" + ex.ToString());
                    continue;
                }
            }
        }
コード例 #15
0
 private void btnNext_Click(object sender, EventArgs e)
 {
     if (this.int_1 != 4)
     {
         this.int_1++;
         this.method_0();
     }
     else
     {
         ITopology          topology;
         Exception          exception2;
         ITopologyContainer pFeatDataset = (ITopologyContainer)this.m_pFeatDataset;
         try
         {
             topology = pFeatDataset.CreateTopology(this.txtTopologyName.Text,
                                                    double.Parse(this.txtLimiteValue.Text), -1, "");
         }
         catch (COMException exception)
         {
             if (exception.ErrorCode == -2147220969)
             {
                 MessageBox.Show("非数据所有者,无法创建拓扑!");
             }
             else
             {
                 MessageBox.Show(exception.Message);
             }
             return;
         }
         catch (Exception exception4)
         {
             exception2 = exception4;
             MessageBox.Show(exception2.Message);
             return;
         }
         int count = this.iarray_1.Count;
         int index = 0;
         while (true)
         {
             if (index >= count)
             {
                 break;
             }
             int tag = (int)this.listViewPri.Items[index].Tag;
             try
             {
                 topology.AddClass((IClass)this.iarray_1.get_Element(index), 5.0, tag, 1, false);
             }
             catch (COMException exception3)
             {
                 if (exception3.ErrorCode != -2147215019)
                 {
                 }
                 Logger.Current.Error("", exception3, "");
             }
             catch (Exception exception6)
             {
                 exception2 = exception6;
                 Logger.Current.Error("", exception2, "");
             }
             index++;
         }
         ITopologyRuleContainer container2 = (ITopologyRuleContainer)topology;
         index = 0;
         while (true)
         {
             if (index >= this.listRule.Items.Count)
             {
                 break;
             }
             try
             {
                 container2.AddRule((ITopologyRule)this.listRule.Items[index].Tag);
             }
             catch (Exception exception7)
             {
                 exception2 = exception7;
                 Logger.Current.Error("", exception2, "");
             }
             index++;
         }
         base.DialogResult = DialogResult.OK;
         base.Close();
     }
 }
コード例 #16
0
        /// <summary>
        /// 从要素数据集中获得第一个拓扑
        /// </summary>
        /// <param name="topoFeatureDataset"></param>
        /// <returns></returns>
        public static ITopology GetFirstTopology(this IFeatureDataset topoFeatureDataset)
        {
            ITopologyContainer topologyContainer = (ITopologyContainer)topoFeatureDataset;

            return(topologyContainer.get_Topology(0));
        }
コード例 #17
0
        /// <summary>
        /// 从要素数据集中获得指定的拓扑
        /// </summary>
        /// <param name="topoFeatureDataset">包含拓扑的要素数据集名称</param>
        /// <param name="topoName">拓扑名称</param>
        /// <returns></returns>
        public static ITopology GetTopologyByName(this IFeatureDataset topoFeatureDataset, string topoName)
        {
            ITopologyContainer topologyContainer = (ITopologyContainer)topoFeatureDataset;

            return(topologyContainer.get_TopologyByName(topoName));
        }
コード例 #18
0
        /// <summary>
        /// 移除拓扑
        /// </summary>
        /// <param name="pFeaDataet">数据集</param>
        /// <param name="pTopoName">拓扑名</param>
        /// <param name="outError">异常</param>
        public void RemoveTopo(IFeatureDataset pFeaDataet, string topoName, out Exception outError)
        {
            outError = null;
            //topoName = topoName + "_Topology";
            IWorkspace              pWorkspace              = pFeaDataet.Workspace;
            IFeatureWorkspace       pFeatureWorkspace       = pWorkspace as IFeatureWorkspace;
            IFeatureWorkspaceManage pFeatureWorkspaceManage = pFeatureWorkspace as IFeatureWorkspaceManage;

            //if (!((IWorkspaceEdit)pWorkspace).IsBeingEdited())
            //{
            //    //((IWorkspaceEdit)pWorkspace).StartEditing(true);
            //    //((IWorkspaceEdit)pWorkspace).StartEditOperation();
            //}
            //    int iCount = 0;
            //    try
            //    {
            try
            {
                ITopologyContainer pTopoCon = pFeaDataet as ITopologyContainer;
                ITopology          pTopo    = pTopoCon.get_TopologyByName(topoName);

                //ISchemaLock pLock = pTopo as ISchemaLock;
                //pLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                ////删除该拓扑下所有的拓扑规则
                //RemoveTopoRule(pTopo, out outError);
                //if (outError != null) return;

                ////删除该拓扑下左右的拓扑图层
                //RemoveTopoClass(pTopo, out outError);
                //if (outError != null) return;

                //删除拓扑
                IDataset     pTopoDt          = pTopo as IDataset;
                IName        pName            = pTopoDt.FullName;
                IDatasetName ptopodatasetname = pName as IDatasetName;
                pFeatureWorkspaceManage.DeleteByName(ptopodatasetname);

                //(pTopo as IDataset).Delete();
                //pTopo.FeatureDataset.Delete();

                //Marshal.ReleaseComObject(pTopo);
                pTopo = null;
                //++iCount;

                //pLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
            catch (Exception ex)
            {
                ////*********************************************
                ////guozheng 2010-12-24 平安夜  added 系统异常日志
                //if (ModData.SysLog == null) ModData.SysLog = new clsWriteSystemFunctionLog();
                //ModData.SysLog.Write(ex);
                ////**********************************************
                outError = ex;
            }
            //}
            //finally
            //{
            //    if (((IWorkspaceEdit)pWorkspace).IsBeingEdited())
            //    {
            //        if (iCount > 0)
            //        {
            //            ((IWorkspaceEdit)pWorkspace).StopEditOperation();
            //            ((IWorkspaceEdit)pWorkspace).StopEditing(true);
            //        }
            //        {
            //            ((IWorkspaceEdit)pWorkspace).AbortEditOperation();
            //            ((IWorkspaceEdit)pWorkspace).StopEditing(true);
            //        }
            //    }
            //}
        }