如何创建一个FeatureClass,IFeatureWorkspace 接口漫谈
IFeatureWorkspace接口是在工作空间中创建对象主要使用的接口。方法:
Description | ||
---|---|---|
CreateFeatureClass | Creates a new standalone feature class under the workspace.//创建一个FeatureClass | |
CreateFeatureDataset | Creates a new feature dataset.//创建一个FeatureDataset | |
CreateQueryDef | Create a query definition object. | |
CreateRelationshipClass | Creates a new relationship class. | |
CreateTable | Creates a new table. //创建表 | |
OpenFeatureClass | Opens an existing feature class.//从工作空间中打开一个FeatureClass | |
OpenFeatureDataset | Opens an existing feature dataset. | |
OpenFeatureQuery | Opens a feature dataset containing a single feature class defined by the specified Query. | |
OpenRelationshipClass | Opens an existing relationship class. | |
OpenRelationshipQuery | The table of a relationship join query. | |
OpenTable | Opens an existing table. //打开存在的表 |
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 == null) return 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; }