• 如何删除要素类 IFeatureWorkspace 接口介绍(1)


    如何删除要素类
    要想删除一个要素类,那么必须先得到这个,在得到这个要素类的时候,我们要学习一个新的接口IFeatureWorkspace。
    IFeatureWorkspace  接口介绍
    这个接口主要是用于管理基于矢量数据的,如表,,要素类,要素数据集等。

    Members

     Description
    Method CreateFeatureClass Creates a new standalone feature class under the workspace.
    Method CreateFeatureDataset Creates a new feature dataset.
    Method CreateQueryDef Create a query definition object.
    Method CreateRelationshipClass Creates a new relationship class.
    Method CreateTable Creates a new table.
    Method OpenFeatureClass Opens an existing feature class.
    Method OpenFeatureDataset Opens an existing feature dataset.
    Method OpenFeatureQuery Opens a feature dataset containing a single feature class defined by the specified Query.
    Method OpenRelationshipClass Opens an existing relationship class.
    Method OpenRelationshipQuery The table of a relationship join query.
    Method OpenTable Opens an existing table.
    Classes that implement IFeatureWorkspace
    ClassesDescription
    Sde3Workspace (esriDataSourcesGDB) ESRI SDE (3.x) Feature Database.
    Sde4Workspace (esriDataSourcesGDB) ESRI SDE (4.x) Feature Database.
    VersionedWorkspace VersionedWorkspace Object.
    Workspace Workspace Object.

     OpenDataset,OpenTable,OpenFeatureClass都是要传入一个相应的名称,如要打开一个名称为PointTest的要素类,只需要在OpenFeatureClass中传入这个要素类的名称,代码如下:
        IWorkspaceFactory pWsFt = new AccessWorkspaceFactoryClass(); 
          IWorkspace pWs = pWsFt.OpenFromFile(WsName, 0); 
        IFeatureWorkspace pFWs = pWs as  IFeatureWorkspace;
     
                    IFeatureClass pFClass = pFWs.OpenFeatureClass("PointTest");
     
    如果是在ArcMap中,我们会切换到Catalog中然后进入相应的数据库,然后删除相应的要素类,这种操作会让我们想到FeatureClas这个对象会提供删除的方法,其实不然,这个删除的方法是定义在Dataset这
    个对象中。
    private void button1_Click(object sender, EventArgs e)
            {
                string WsName = WsPath();
     
                if( WsName !="")
                {
     
     
                    IWorkspaceFactory pWsFt = new AccessWorkspaceFactoryClass();
     
                    IWorkspace pWs = pWsFt.OpenFromFile(WsName, 0);
     
                    IFeatureWorkspace pFWs = pWs as  IFeatureWorkspace;
     
                    IFeatureClass pFClass = pFWs.OpenFeatureClass("PointTest");
     
                    IDataset pDatset = pFClass as IDataset;
     
                    pDatset.Delete();
     
                } 
            }

     

     
  • 相关阅读:
    centos已经安装了python2,同时安装python3
    linux下判断磁盘是ssd还是hdd
    Java中如何判断两个对象是否相等
    NPOI导出Excel和基于office导出Excel比较
    asp
    又找到了一个blog
    关于宋朝及中国历史的一点想法
    Android中实现EditText圆角
    Python小练习
    软件架构设计(三) 架构、架构师和架构设计
  • 原文地址:https://www.cnblogs.com/qiushuixizhao/p/3242585.html
Copyright © 2020-2023  润新知