If asRatio = TRUE, the expansion is multiplicative. XMin = (XMin - dx*Width)/2 YMin = (YMin - dy*Height)/2 XMax = (XMax + dx*Width)/2 YMax = (YMax + dy*Height)/2
The Envelope remains centered at the same position. 复制代码
IEnvelope接口的第十个方法Offset (X, Y) (方法,将已有的一个边框的按照输入参数的大小来进行水平竖直的移动) 例子代码:
Private Sub btnOffset_Click() m_pEnveLope.Offset 10, 20 update_props End Sub
注意!!!
The new position of the Envelope is as follows: new XMin= old XMin + X new YMin = old YMin + Y new XMax = old XMax + X new YMax = old YMax + Y 复制代码
11. 关于IFeature接口(esriGeoDatabase) IFeature接口的第一个属性Class(只读)
IFeature接口的第二个方法Delete(方法,删除该行。因为一个Feature在表格中对应的就是一行数据,删除该行就能相应的删除这个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要素 例子代码:
Dim pFeature As IFeature
Dim pGeo As IGeometry
Set pGeo = pFeature.ShapeCopy 'Change the shape
pFeature.Shape = pGeo pFeature.Store
复制代码
IFeature接口的第九个属性Value(读写,利用字段的索引进行对该要素该字段的值的读写) 注意,索引Index是从0开始的。 object.Value(Index ) = [ value ]
IFeature 接口的第十个属性Table(只读,将该行要素转换成ITable格式的数据,即可对一张表进行数据操作,具体方法查看ITable接口) 例子代码:
Dim pTable As ITable Set pTable = pRow.Table 复制代码
12. 关于IRow接口(esriGeoDatabase) IRow接口的第一个方法Delete(方法,删除该行)
IRow接口的第二个属性Fields(只读,获取该Feature要素的字段集合,返回值为IFields类型)此方法类似于IFeature接口的Fields属性 IRow 接口的第三个方法Store(方法,保存该行。)此方法类似于IFeature接口的Store方法 IRow接口的第四个属性Table(只读,获取该行所在的表格,返回值为ITable类型) 例子代码:
Dim pTable As ITable Set pTable = pRow.Table
复制代码
IRow接口的第五个属性Value(Index) (读写,获取该行在参数索引的字段的值,注意,索引Index是从0开始的。) object.Value(Index ) = [ value ]
IRow接口的第六个属性HasOID(只读,判断指出该行是否有OID) IRow接口的第七个属性OID(只读,获取该行的OID值) 例子代码:
If pRow.HasOID Then Debug.Print pRow.OID End If
复制代码
13. 关于IFeatureClass接口(esriGeoDatabase) Dim pFeatcls As IFeatureClass Dim pFeatLayer As IFeatureLayer Dim pDoc As IMxDocument Dim pMap As IMap
Set pDoc = ThisDocument
Set pMap = pDoc.Maps.Item(0) Set pFeatLayer = pMap.Layer(0)
Set pFeatcls = pFeatLayer.FeatureClass 复制代码
IFeatureClass接口的第一个方法AddField(Field) (方法,增加一个属性字段到这个要素类,其中传入的参数为一个IField接口的变量,此变量可以由其他要素类获得并赋值给要操作的要素类,可用IFeilds接口的Field属性来获得)
IFeatureClass接口的第二个方法DeleteField(Field) (方法,删除一个属性字段,其中传入的参数为一个IField接口的变量)
IFeatureClass接口的第三个属性Fields(只读,获取该要素类的全部属性字段,返回一个IFields类型的变量) 例子代码:
'Assume we have a reference to a feature class, pFC Dim pFields As IFields Dim pField As IField Set pFields = pFC.Fields
Set pField = pFields.Field(pFields.FindField(\
pFC.DeleteField pField 复制代码
IFeatureClass接口的第四个方法FindField(Name) (方法,去查找在该要素类里面是否含有参数名字的属性字段,如果有,则返回索引,没有,则返回-1) IFeatureClass接口的第五个属性AreaField(只读,获取属性字段为geometry的那一个Field) 例子代码:
Dim pFeatcls As IfeatureClass Dim pFeatLayer As IFeatureLayer Dim pDoc As IMxDocument Dim pMap As Imap
Set pDoc = ThisDocument
Set pMap = pDoc.Maps.Item(0) Set pFeatLayer = pMap.Layer(0)
Set pFeatcls = pFeatLayer.FeatureClass Dim pFld As IField
Set pFld = pFeatcls.AreaField
If Not pFld Is Nothing Then MsgBox pFld.Name End If 复制代码
IFeatureClass接口的第六个方法Search (filter, Recycling) (方法,去得到一个IFeatureCursor类型的游标,该游标由filter来控制赛选,如果filter等于null,则返回整个featureclass的游标,再用IfeatureCursor的NextFeature的方法依次得到每一个Feature) 例子代码:
Dim pFeatcls As IFeatureClass Dim pFeatLayer As IFeatureLayer Dim pDoc As IMxDocument Dim pMap As IMap
Set pDoc = ThisDocument
Set pMap = pDoc.Maps.Item(0) Set pFeatLayer = pMap.Layer(0)
Set pFeatcls = pFeatLayer.FeatureClass
' +++ create the query filter, and give ' +++ it a where clause Dim pQFilt As IQueryFilter
Dim pFeatCur As IFeatureCursor
Set pQFilt = New QueryFilter
pQFilt.WhereClause = \ Set pFeatCur = pFeatcls.Search(pQFilt, False)
' +++ get the area field Dim pFlds As IFields Dim pFld As IField Dim lAIndex As Long
Set pFlds = pFeatcls.Fields
lAIndex = pFlds.FindField (\ Set pFld = pFlds.Field(lAIndex)
' +++ a variable to hold the total area Dim dtotArea As Double dtotArea = 0#
' +++ loop through all of the features and ' +++ calculate the sum of all of the areas Dim pFeat As IFeature
Set pFeat = pFeatCur.NextFeature Do
dtotArea = dtotArea + pFeat.Value(lAIndex) Set pFeat = pFeatCur.NextFeature Loop Until pFeat Is Nothing
' +++ send the total area to a message box MsgBox dtotArea 复制代码

