如何创建一个要素数据类 IField,IFieldEdit,IFields,IFieldsEditI,GeometryDef,IGeometryDefEdit接口...

如何创建一个要素数据类
创建要素类用到了IFeatureWorkspace.CreateFeatureClass方法,在这个方法中有众多的参数,为了满足这些参数,我们要学习和了解下面的接口.
IField,IFieldEdit,IFields,IFieldsEditI,GeometryDef,IGeometryDefEdit接口
字段对应表中的一列,一个要素类必须有至少2个字段,而多个字段的集合就构成了字段集,在要素类中,有一个特殊的字段,描述了空间对象,我们称之为几何字段,其中GeometryDef是用来设计几何字段的。这个几何字段定义了要素类的类型,比如说我们要在Catalog创建一个点要素类,那么我们必须指定他的类型为Point。

而上面这6个接口,其实是三类,以Edit结尾的接口是可写的,也就是说对字段,字段集合,以及几何字段的编辑都是通过后者完成的。空间数据的一个重要属性就是参考系,参考系也是在GeometryDef中定义的。
注意 在NET中,会遇到以“_2”结尾的属性,这些属性是可写的。

IGeometryDefEdit Interface接口

Members
 AllPropertiesMethodsInheritedNon-inheritedDescription
Read-only propertyAvgNumPointsThe estimated average number of points per feature.
Write-only propertyAvgNumPointsThe estimated average number of points per feature.
Read-only propertyGeometryTypeThe enumerated geometry type.
Write-only propertyGeometryTypeThe geometry type.
Read-only propertyGridCountThe number of spatial index grids.
Write-only propertyGridCountThe number of spatial index grids.
Read-only propertyGridSizeThe size of a spatial index grid.
Write-only propertyGridSizeThe size of a spatial index grid.
Read-only propertyHasMIndicates if the feature class has measure (M) values.
Write-only propertyHasMIndicates if the feature class will support M values.
Write-only propertyHasZIndicates if the feature class will support Z values.
Read-only propertyHasZIndicates if the featureClass has Z values.
Read-only propertySpatialReferenceThe spatial reference for the dataset.
Write-only propertySpatialReferenceThe spatial reference of the dataset.

 

Inherited Interfaces
InterfacesDescription
IGeometryDefProvides access to members that return information about the geometry definition.
 

 

Classes that implement IGeometryDefEdit

 

ClassesDescription
GeometryDefESRI Geometry Definition object.

 

 //定义一个几何字段,类型为点类型
             ISpatialReference pSpatialReference = axMapControl1.ActiveView.FocusMap.SpatialReference; //空间参考系
 
             IGeometryDefEdit pGeoDef = new GeometryDefClass();
             IGeometryDefEdit pGeoDefEdit = pGeoDef as IGeometryDefEdit;
             pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
             pGeoDefEdit.SpatialReference_2 = pSpatialReference;
 
             //定义一个字段集合对象
             IFields pFields = new FieldsClass();
             IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;
 
             //定义单个的字段
             IField pField = new FieldClass();
             IFieldEdit pFieldEdit = (IFieldEdit)pField;
 
             pFieldEdit.Name_2 = "SHAPE";
             pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
             pFieldsEdit.AddField(pField);
             pFieldEdit.GeometryDef_2 = pGeoDef;
 
             //定义单个的字段,并添加到字段集合中
             pField = new FieldClass();
             pFieldEdit = (IFieldEdit)pField;
             pFieldEdit.Name_2 = "STCD";
             pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
             pFieldsEdit.AddField(pField);
 
             //定义单个的字段,并添加到字段集合中
             pField = new FieldClass();
             pFieldEdit = (IFieldEdit)pField;
             pFieldEdit.Name_2 = "SLM10";
             pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
             pFieldsEdit.AddField(pField);
             //定义单个的字段,并添加到字段集合中
             pField = new FieldClass();
             pFieldEdit = (IFieldEdit)pField;
             pFieldEdit.Name_2 = "SLM20";
             pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
             pFieldsEdit.AddField(pField);
             //定义单个的字段,并添加到字段集合中
             pField = new FieldClass();
             pFieldEdit = (IFieldEdit)pField;
             pFieldEdit.Name_2 = "SLM40";
             pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
             pFieldsEdit.AddField(pField);
 
             IWorkspaceFactory pFtWsFct = new AccessWorkspaceFactory();
 
             IFeatureWorkspace pWs = pFtWsFct.OpenFromFile(@"E:\arcgis\Engine\s.mdb", 0) as
IFeatureWorkspace;
 
 
             IFeatureClass pFtClass = pWs.CreateFeatureClass("Test", pFields, null, null,
esriFeatureType.esriFTSimple, "SHAPE", null)

 

转载于:https://www.cnblogs.com/qiushuixizhao/p/3242685.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值