首页 > 代码库 > AE创建拓扑
AE创建拓扑
转自原文 AE创建拓扑
/// <summary> /// 创建拓朴 /// </summary> /// <param name="featureWorkspace">要素集工作空间</param> /// <param name="featuredatasetName"></param> /// <param name="featureClassName"></param> /// <returns></returns> 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; } private void CreateTopButton_Click(object sender, EventArgs e) { //打开目标数据库 IWorkspace fWorkspace = open_pGDB_Workspace("e:\\Topo.mdb"); IFeatureWorkspace fW = fWorkspace as IFeatureWorkspace; //启动编辑 IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)fWorkspace; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); //调用创建拓朴的方法 ITopology topology = Create_Topology(fW, "HN_DS", "HN", "Polygon_Topo"); //停止编辑 workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); if (topology != null) { MessageBox.Show("创建拓朴成功!"); } }
启动编辑是后来加上去的,若不启动编辑,则提示没有权限执行操作。
AE创建拓扑
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。