就是一行数据,删除该行就能相应的删除这个Feature)
IFeature接口的第三个属性Extent(只读,获取该Feature要素在地图上的一个矩形范围,返回值为IEnvelope类型)
IFeature接口的第四个属性FeatureType(只读,获取该Feature要素的要素类型,返回值为枚举类型的esriFeatureType)
IFeature接口的第五个属性Fields(只读,获取该Feature要素的字段集合,返回值为IFields类型)
IFeature接口的第六个属性Shape(读写,获取该Feature要素的图形,返回值为IGeometry类型,或者各种实体化的类型,如IPolyline)
IFeature接口的第七个属性ShapeCopy(只读,克隆该Feature要素的几何图形,返回值为IGeometry类型)
IFeature 接口的第八个方法Store(方法,保存该行。) 此属性可用于对Feature要素的几何图形进行操作,步骤如下:
用IFeature.ShapeCopy方法获取一个已经存在的Geometry,或者新建一个Geometry 对Geometry进行操作
通过IFeature.Shape属性将Geometry写入 通过IFeature.Store方法保存该Feature要素 例子代码:
1. Dim pFeature As IFeature 2. Dim pGeo As IGeometry 3. Set pGeo = pFeature.ShapeCopy 4. 'Change the shape 5. pFeature.Shape = pGeo 6. pFeature.Store
IFeature接口的第九个属性Value(读写,利用字段的索引进行对该要素该字段的值的读写) 注意,索引Index是从0开始的。 object.Value(Index ) = [ value ]
IFeature 接口的第十个属性Table(只读,将该行要素转换成ITable格式的数据,即可对一张表进行数据操作,具体方法查看ITable接口) 例子代码:
1. Dim pTable As ITable 2. Set pTable = pRow.Table
12. 关于IRow接口(esriGeoDatabase)
IRow接口的第一个方法Delete(方法,删除该行)
IRow接口的第二个属性Fields(只读,获取该Feature要素的字段集合,返回值为IFields类型)此方法类似于IFeature接口的Fields属性
IRow 接口的第三个方法Store(方法,保存该行。)此方法类似于IFeature接口的Store方法
IRow接口的第四个属性Table(只读,获取该行所在的表格,返回值为ITable类型) 例子代码:
1. Dim pTable As ITable 2. Set pTable = pRow.Table
IRow接口的第五个属性Value(Index) (读写,获取该行在参数索引的字段的值,注意,索引Index是从0开始的。) object.Value(Index ) = [ value ]
IRow接口的第六个属性HasOID(只读,判断指出该行是否有OID) IRow接口的第七个属性OID(只读,获取该行的OID值) 例子代码:
1. If pRow.HasOID Then 2. Debug.Print pRow.OID 3. End If
13. 关于IFeatureClass接口(esriGeoDatabase) 1. Dim pFeatcls As IFeatureClass 2. Dim pFeatLayer As IFeatureLayer 3. Dim pDoc As IMxDocument 4. Dim pMap As IMap 5.
6. Set pDoc = ThisDocument 7. Set pMap = pDoc.Maps.Item(0) 8. Set pFeatLayer = pMap.Layer(0)
9. Set pFeatcls = pFeatLayer.FeatureClass
IFeatureClass接口的第一个方法AddField(Field) (方法,增加一个属性字段到这个要素类,其中传入的参数为一个IField接口的变量,此变量可以由其他要素类获得并赋值给要操作的要素类,可用IFeilds接口的Field属性来获得)
IFeatureClass接口的第二个方法DeleteField(Field) (方法,删除一个属性字段,其中传入的参数为一个IField接口的变量)
IFeatureClass接口的第三个属性Fields(只读,获取该要素类的全部属性字段,返回一个IFields类型的变量) 例子代码:
1. 'Assume we have a reference to a feature class, pFC 2. Dim pFields As IFields 3. Dim pField As IField 4. Set pFields = pFC.Fields
5. Set pField = pFields.Field(pFields.FindField(\6.
7. pFC.DeleteField pField
IFeatureClass接口的第四个方法FindField(Name) (方法,去查找在该要素类里面是否含有参数名字的属性字段,如果有,则返回索引,没有,则返回-1)
IFeatureClass接口的第五个属性AreaField(只读,获取属性字段为geometry的那一个Field) 例子代码:
1. Dim pFeatcls As IfeatureClass 2. Dim pFeatLayer As IFeatureLayer 3. Dim pDoc As IMxDocument 4. Dim pMap As Imap 5.
6. Set pDoc = ThisDocument 7. Set pMap = pDoc.Maps.Item(0) 8. Set pFeatLayer = pMap.Layer(0)
9. Set pFeatcls = pFeatLayer.FeatureClass 10. Dim pFld As IField
11. Set pFld = pFeatcls.AreaField 12.
13. If Not pFld Is Nothing Then 14. MsgBox pFld.Name 15. End If
IFeatureClass接口的第六个方法Search (filter, Recycling) (方法,去得到一个IFeatureCursor类型的游标,该游标由filter来控制赛选,如果filter等于null,则返回整个featureclass的游标,再用IfeatureCursor的NextFeature的方法依次得到每一个Feature) 例子代码:
1. Dim pFeatcls As IFeatureClass 2. Dim pFeatLayer As IFeatureLayer 3. Dim pDoc As IMxDocument 4. Dim pMap As IMap 5.
6. Set pDoc = ThisDocument 7. Set pMap = pDoc.Maps.Item(0) 8. Set pFeatLayer = pMap.Layer(0) 9. Set pFeatcls = pFeatLayer.FeatureClass 10.
11. ' +++ create the query filter, and give 12. ' +++ it a where clause 13. Dim pQFilt As IQueryFilter 14. Dim pFeatCur As IFeatureCursor 15.
16. Set pQFilt = New QueryFilter
17. pQFilt.WhereClause = \18. Set pFeatCur = pFeatcls.Search(pQFilt, False) 19.
20. ' +++ get the area field 21. Dim pFlds As IFields
22. Dim pFld As IField 23. Dim lAIndex As Long 24.
25. Set pFlds = pFeatcls.Fields 26. lAIndex = pFlds.FindField (\27. Set pFld = pFlds.Field(lAIndex) 28.
29. ' +++ a variable to hold the total area 30. Dim dtotArea As Double 31. dtotArea = 0# 32.
33. ' +++ loop through all of the features and 34. ' +++ calculate the sum of all of the areas 35. Dim pFeat As IFeature
36. Set pFeat = pFeatCur.NextFeature 37. Do
38. dtotArea = dtotArea + pFeat.Value(lAIndex) 39. Set pFeat = pFeatCur.NextFeature 40. Loop Until pFeat Is Nothing 41.
42. ' +++ send the total area to a message box 43. MsgBox dtotArea
IFeatureClass接口的第七个方法Insert(useBuffering) (方法,去得到一个IFeatureCursor类型的游标,来用作插入新的Features,useBuffering是一个布尔型参数,当为True时即可以插入新的Feature,再用IFeatureCursor的InsertFeature (buffer )的方法去插入一个新的Feature) 例子代码:
1. Dim pFeatcls As IFeatureClass 2. Dim pFeatLayer As IFeatureLayer 3. Dim pDoc As IMxDocument 4. Dim pMap As Imap
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库ArcEngine - 开发接口集(5)在线全文阅读。
相关推荐: