如何创建一个FeatureClass,IFeatureWorkspace 接口漫谈

IFeatureWorkspace接口是在工作空间中创建对象主要使用的接口。方法:

  Description
Method CreateFeatureClass Creates a new standalone feature class under the workspace.//创建一个FeatureClass
Method CreateFeatureDataset Creates a new feature dataset.//创建一个FeatureDataset
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.//从工作空间中打开一个FeatureClass
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.                                            //打开存在的表
1、创建一个FeatureClass

public IFeatureClass CreateFeatureClass (
    string Name,
    IFields Fields,
    UID CLSID,
    UID EXTCLSID,
    esriFeatureType FeatureType,
    string ShapeFieldName,
    string ConfigKeyword
);
esriFeatureType见点击打开链接
2、创建FeatureDataset

public IFeatureDataset CreateFeatureDataset (
    string Name,
    ISpatialReference SpatialReference
);
3、

public IQueryDef CreateQueryDef (
);
4、
public IFeatureClass OpenFeatureClass (
    string Name
);

打开一个FeatureClass
(Workspace as IFeatureWorkspace).OpenFeatureClass(FeatureClassName);

创建例子:
        /// <summary>
        /// 创建要素类
        /// </summary>
        /// <param name="workspace"></param>
        /// <param name="featureDataset"></param>
        /// <param name="featureClassName"></param>
        /// <param name="fields"></param>
        /// <param name="CLSID"></param>
        /// <param name="CLSEXT"></param>
        /// <param name="strConfigKeyword"></param>
        /// <returns></returns>
        public static IFeatureClass CreateFeatureClass(IFeatureDataset featureDataset, String featureClassName, IFields fields)
        {
            if (_workSpaceInstance == nullreturn null;
            IFeatureClass featureClass = null;
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)_workSpaceInstance; 

            // assign the class id value if not assigned
            ESRI.ArcGIS.esriSystem.UID CLSID = null;
            ESRI.ArcGIS.esriSystem.UID CLSEXT = null;
            string strConfigKeyword = "";
            if (CLSID == null)
            {
                CLSID = new ESRI.ArcGIS.esriSystem.UIDClass();
                CLSID.Value = "esriGeoDatabase.Feature";
            }

            System.String strShapeField = "";

            // locate the shape field
            for (Int32 j = 0; j < fields.FieldCount; j++)
            {
                esriFieldType dd = fields.get_Field(j).Type;
                if (dd == esriFieldType.esriFieldTypeGeometry)
                {
                    strShapeField = fields.get_Field(j).Name;
                }
            }

            // finally create and return the feature class
            if (featureDataset != null)
            {
                featureClass = featureDataset.CreateFeatureClass(featureClassName, fields, CLSID, CLSEXT, esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
            }
            
            return featureClass;
        }

posted @ 2014-12-30 15:13  静以养身 俭以养德  阅读(357)  评论(0编辑  收藏  举报