• 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("创建拓朴成功!");
        }
    }

    启动编辑是后来加上去的,若不启动编辑,则提示没有权限执行操作。

  • 相关阅读:
    ArcGIS10.1的安装问题
    谁是农业信息化的第一推动力
    名片
    【旺铺2012分享】导航CSS代码使用修改技巧!
    新旺铺教程之导航12
    新旺铺教程之导航
    Photoshop制作通透的紫色宝石字
    用PS怎么画虚线圆?
    一张彩色图片,如何用Photoshop处理成一张轮廓图(就是变成刚用铅笔画出来时的那样)_...
    php从入门到放弃系列-01.php环境的搭建
  • 原文地址:https://www.cnblogs.com/arxive/p/6262963.html
Copyright © 2020-2023  润新知