码迷,mamicode.com
首页 > 其他好文 > 详细

AE创建拓扑

时间:2017-01-08 23:55:40      阅读:49      评论:0      收藏:0      [点我收藏+]

标签:private   工作   方法   any   ddc   exception   write   ase   boolean   

转自原文 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创建拓扑

标签:private   工作   方法   any   ddc   exception   write   ase   boolean   

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 mamicode.com 版权所有 京ICP备13008772号-2
迷上了代码!