ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:20.19KB ,
资源ID:7039702      下载积分:2 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7039702.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(实验指导书GeoDataBase2.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

实验指导书GeoDataBase2.docx

1、实验指导书GeoDataBase21 GeoDataBase1.1如何建立文件连接(Join / Link)本例实现的是如何将地图中的一个FeatureLayer的属性表与另一个数据文件建立连接。 要点首先需要定义两个ITable接口对象,分别用来获得地图中的属性表和需要连接的数据文件,再通过IMemoryRelationshipClassFactory.Open方法将两个ITable接口对象根据某个关键字段建立连接,最后使用IDisplayRelationshipClass.DisplayRelationshipClass方法将显示该连接主要用到IMemoryRelationshipClas

2、sFactory接口,IRelationshipClass接口和IDisplayRelationshipClass接口。 程序说明函数Join是将当前激活的地图中名称为sLayerName的图层和路径为sFilePath、文件名为sFileName的文件按字段名为sFieldName的字段进行连接。 代码Private Function Join(ByVal sLayerName As String, ByVal sFilePath As String, _ ByVal sFileName As String, ByVal sFieldName As String) As Boolean Di

3、m pMxDocument As IMxDocument Dim pMap As IMap Dim pWorkspaceFactory As IWorkspaceFactory Dim pWorkspace As IWorkspace Dim pFeatureWorkspace As IFeatureWorkspace Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass As IFeatureClass Dim pPrimaryTable As ITable Dim pForeignTable As ITable Dim pDisplayT

4、able As IDisplayTable Dim pMemoryRelationshipCF As IMemoryRelationshipClassFactory Dim pRelationshipClass As IRelationshipClass Dim pDisplayRelationshipC As IDisplayRelationshipClass Dim nNumber As Integer Dim sForeignFile As String On Error GoTo ErrorHandler: Join = False sForeignFile = Dir(sFilePa

5、th & & sFileName) If (sForeignFile = ) Then MsgBox The ForeignFile is not exist. Exit Function End If Set pWorkspaceFactory = New ShapefileWorkspaceFactory Set pWorkspace = pWorkspaceFactory.OpenFromFile(sFilePath, 0) Set pFeatureWorkspace = pWorkspace Set pForeignTable = pFeatureWorkspace.OpenTable

6、(sFileName) Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap For nNumber = 0 To pMap.LayerCount - 1 If pMap.Layer(nNumber).Name = sLayerName Then Set pFeatureLayer = pMap.Layer(nNumber) Exit For End If Next If pFeatureLayer Is Nothing Then MsgBox No Layers Name is & sLayerName Exit Fun

7、ction End If Set pDisplayTable = pFeatureLayer Set pFeatureClass = pDisplayTable.DisplayTable Set pPrimaryTable = pFeatureClass Set pMemoryRelationshipCF = New MemoryRelationshipClassFactory Set pRelationshipClass = pMemoryRelationshipCF.Open(TabletoLayer, pPrimaryTable, sFieldName, _ pForeignTable,

8、 sFieldName, forward, backward, esriRelCardinalityOneToOne) Set pDisplayRelationshipC = pFeatureLayer pDisplayRelationshipC.DisplayRelationshipClass pRelationshipClass, esriLeftOuterJoin Join = True Exit FunctionErrorHandler: MsgBox Err.DescriptionEnd FunctionPrivate Sub UIButtonControl1_Click() Dim

9、 pVBProject As VBProjectOn Error GoTo ErrorHandler: Set pVBProject = ThisDocument.VBProject Join WorldCountries, pVBProject.FileName & . & data, Continents.dbf, FID Exit SubErrorHandler: MsgBox Err.DescriptionEnd Sub1.2如何浏览纪录(属性查询)本例实现的是如何按照给定的查询要求,找出满足要求的记录。 要点创建IQueryFilter接口对象,设置IQueryFilter.Wher

10、eClause属性为属性查询条件,使用IFeatureClass.Search方法进行查询,返回ICursor接口对象主要用到了IFeatureClass接口、IFeature接口、IFeatureCursor接口和IQueryFilter接口。 程序说明函数SelectFeatures在当前激活的Map的第一个图层中查出FID 2的所有记录。 代码Private Sub SelectFeatures() Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pFeatureLayer As IFeatureLayer Dim pFeature

11、Class As IFeatureClass Dim pFeature As IFeature Dim pFeatureCursor As IFeatureCursorDim pQueryFilter As IqueryFilter On Error GoTo ErrorHandler: Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap If (pMap.LayerCount = 0) Then MsgBox (缺少数据) Exit Sub End If Set pFeatureLayer = pMap.Layer(0

12、) Set pFeatureClass = pFeatureLayer.FeatureClass Set pQueryFilter = New QueryFilter pQueryFilter.WhereClause = FID 2 Set pFeatureCursor = pFeatureClass.Search(pQueryFilter, False) Set pFeature = pFeatureCursor.NextFeature Do While Not pFeature Is Nothing More Operations Set pFeature = pFeatureCursor

13、.NextFeature Loop Exit SubErrorHandler: MsgBox Err.DescriptionEnd SubPrivate Sub UIButtonControl1_Click()On Error GoTo ErrorHandler: SelectFeatures Exit SubErrorHandler: MsgBox Err.DescriptionEnd Sub1.3如何编辑记录本例实现的是如何修改FeatureClass中某条记录(Feature)的值。 要点通过IFeatureClass.Update方法获得可修改记录的IFeatureCursor接口对象

14、,使用IFeatureCursor.NextFeature方法获得Ifeatur接口对象,修改其属性值,通过IFeatureCursor.UpdateFeature方法提交IFeature修改内容。主要用到IFeatureCursor接口 程序说明函数OpenFeatureClass获得当前激活的Map中第一层的IFeatureClass接口对象。函数EditFeature修改pFeatureClass中第一条记录的第七个字段的值。 代码Private Function EditFeature(pFeatureClass As IFeatureClass) As Boolean Dim pFe

15、ature As IFeature Dim pFeatureCursor As IFeatureCursor On Error GoTo ErrorHandler: EditFeature = False If (pFeatureClass Is Nothing) Then Exit Function End If Set pFeatureCursor = pFeatureClass.Update(Nothing, False) Set pFeature = pFeatureCursor.NextFeature If (Not pFeature Is Nothing) Then pFeatur

16、e.Value(6) = New Place pFeatureCursor.UpdateFeature pFeature MsgBox (修改成功) EditFeature = True Else MsgBox (修改失败) End If Exit FunctionErrorHandler: MsgBox Err.DescriptionEnd FunctionPrivate Function OpenFeatureClass() As IFeatureClass Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pFeatureLayer

17、As IFeatureLayer Dim pFeatureClass As IFeatureClass On Error GoTo ErrorHandler: Set OpenFeatureClass = Nothing Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap If (pMap.LayerCount = 0) Then MsgBox (缺少数据) Exit Function End If Set pFeatureLayer = pMap.Layer(0) Set pFeatureClass = pFeatur

18、eLayer.FeatureClass Set OpenFeatureClass = pFeatureClass Exit FunctionErrorHandler: MsgBox Err.DescriptionEnd FunctionPrivate Sub UIButtonControl1_Click()On Error GoTo ErrorHandler: Dim pFeatureClass As IFeatureClass Set pFeatureClass = OpenFeatureClass() EditFeature pFeatureClass Exit SubErrorHandl

19、er: MsgBox Err.DescriptionEnd Sub1.5如何增加记录本例要实现的是如何在FeatureClass中新增一条记录(Feature)。 要点通过IFeatureClass.Insert方法获得可插入记录的游标IFeatureCursor,然后使用IFeatureClass.CreateFeatureBuff方法获得IFeatureBuffer接口实例,使用IFeatureCursor.InsertFeature方法插入记录。主要用到IFeatureCursor接口。 程序说明函数OpenFeatureClass获得当前激活的Map中第一层的IFeatureClass

20、接口对象。函数InsertFeature在pFeatureClass中添加一条记录。 代码Private Function InsertFeature(pFeatureClass As IFeatureClass) As Boolean Dim pFeatureCursor As IFeatureCursor Dim pFeatureBuffer As IFeatureBuffer Dim nFeatureNumber As Integer On Error GoTo ErrorHandler: InsertFeature = False If (pFeatureClass Is Nothin

21、g) Then Exit Function End If Set pFeatureCursor = pFeatureClass.Insert(True) Set pFeatureBuffer = pFeatureClass.CreateFeatureBuffer nFeatureNumber = -1 pFeatureBuffer.Value(6) = Insert Land nFeatureNumber = pFeatureCursor.InsertFeature(pFeatureBuffer) If (nFeatureNumber -1) Then MsgBox (添加了第 & nFeat

22、ureNumber & 条记录) InsertFeature = True Else MsgBox (添加失败) InsertFeature = False End If Exit FunctionErrorHandler: MsgBox Err.DescriptionEnd FunctionPrivate Function OpenFeatureClass() As IFeatureClass Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass

23、 As IFeatureClass On Error GoTo ErrorHandler: Set OpenFeatureClass = Nothing Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap If (pMap.LayerCount = 0) Then MsgBox (缺少数据) Exit Function End If Set pFeatureLayer = pMap.Layer(0) Set pFeatureClass = pFeatureLayer.FeatureClass Set OpenFeatur

24、eClass = pFeatureClass Exit FunctionErrorHandler: MsgBox Err.DescriptionEnd FunctionPrivate Sub UIButtonControl1_Click()On Error GoTo ErrorHandler: Dim pFeatureClass As IFeatureClass Set pFeatureClass = OpenFeatureClass() InsertFeature pFeatureClass Exit SubErrorHandler: MsgBox Err.DescriptionEnd Su

25、b1.6如何删除记录本例要实现的是如何在FeatureClass中删除一条记录(Feature)。 要点获得游标IFeatureCursor,然后定义IFeature接口对象,并获得要删除的记录,最后使用IFeature.Delete方法删除记录。主要用到IFeature接口和IFeatureCursor接口。 程序说明函数OpenFeatureClass获得当前激活的Map中第一层的IFeatureClass接口对象。函数DeleteFeature删除PLACENAME字段值为”Insert Land”的所有记录。 代码Private Sub DeleteFeature(pFeatureCl

26、ass As IFeatureClass) Dim pFeature As IFeature Dim pFeatureCursor As IFeatureCursor Dim pQueryFilter As IQueryFilter Dim nFeatureNumber As Integer On Error GoTo ErrorHandler: If (pFeatureClass Is Nothing) Then Exit Sub End If Set pQueryFilter = New QueryFilter pQueryFilter.WhereClause = PLACENAME =

27、Insert Land Set pFeatureCursor = pFeatureClass.Search(pQueryFilter, False) Set pFeature = pFeatureCursor.NextFeature nFeatureNumber = 0 Do While Not pFeature Is Nothing pFeature.Delete nFeatureNumber = nFeatureNumber + 1 Set pFeature = pFeatureCursor.NextFeature Loop MsgBox (Delete & nFeatureNumber

28、& Features) Exit SubErrorHandler: MsgBox Err.DescriptionEnd SubPrivate Function OpenFeatureClass() As IFeatureClass Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass As IFeatureClass On Error GoTo ErrorHandler: Set OpenFeatureClass = Nothing Set pMx

29、Document = ThisDocument Set pMap = pMxDocument.FocusMap If (pMap.LayerCount = 0) Then MsgBox (缺少数据) Exit Function End If Set pFeatureLayer = pMap.Layer(0) Set pFeatureClass = pFeatureLayer.FeatureClass Set OpenFeatureClass = pFeatureClass Exit FunctionErrorHandler: MsgBox Err.DescriptionEnd Function

30、Private Sub UIButtonControl1_Click()On Error GoTo ErrorHandler: Dim pFeatureClass As IFeatureClass Set pFeatureClass = OpenFeatureClass() DeleteFeature pFeatureClass Exit SubErrorHandler: MsgBox Err.DescriptionEnd Sub1.7如何纪录排序(ITableSort)本例要实现的是如何将一个FeatureClass中的数据按某字段的值进行排序。 要点定义ITableSort接口对象,并用TableSort类实现之,设置排序所用到的字段、排序方式(升序或降序)以及排序的数据源,然后使用ITableSort.Sort方法进行排序。主要用到ITableSort接口。 程序说明函数OpenFeatureClass获得当前激活的Map中第一层的IFeatureClass接口对象。函数SortFeatures按照pFeatureClass的第五个字段值对pFeatureClass的

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1