mapobjects实验

上传人:ths****59 文档编号:45116500 上传时间:2018-06-15 格式:DOC 页数:14 大小:861KB
返回 下载 相关 举报
mapobjects实验_第1页
第1页 / 共14页
mapobjects实验_第2页
第2页 / 共14页
mapobjects实验_第3页
第3页 / 共14页
mapobjects实验_第4页
第4页 / 共14页
mapobjects实验_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《mapobjects实验》由会员分享,可在线阅读,更多相关《mapobjects实验(14页珍藏版)》请在金锄头文库上搜索。

1、1本科学生验证性本科学生验证性 实验报告实验报告姓名 查建勋 学号 104130101专业 GIS 班级 10 地信 实验课程名称 GIS 设计与开发 指导教师及职称 彭双云 开课学期 2013 至 2014 学年 第一 学期上课时间 2013 年 10 月 9 日云南师范大学旅游与地理科学学院地理信息系统系2一、实验设计一、实验设计实验名称:SearchByDistance 和 SearchShape 联合空间数据查询功能的实 现实验时间:2013-11-19小组合作:是()否()小组成员:无1、实验内容(含实验原理介绍):实验内容(含实验原理介绍):1.1 设计软件界面和添加需要的空间 1

2、.2 进行编程并进行调试 1.3 对程序进行优化并进行调试1.4 实现如下界面功能功能解析: 1.4.1 能够通过绘制点线面等图形,基于 MO 提供的空间关系进行查询,并显示查询结果; 1.4.2 能够根据图上选择的地理要素,基于 MO 提供的空间关系进行查询,并显示查询结果;1.4.3 根据查询出来的结果进行空间定位与显示。2、实验目的:实验目的:学会使用 SearchByDistance 和 SearchShape 方法,能利用这两种方法进行空间查询,并 将查询结果进行显示,根据查询记录定位、显示相关的地理要素。3、设计实验相关情况介绍(包含使用软件以及实验设备等):设计实验相关情况介绍(

3、包含使用软件以及实验设备等):(1)使用软件:MO 软件和 VB 软件 (2)实验设备:计算机、Windowsxp 系统、4、实验过程、方法步骤:实验过程、方法步骤: 4.1 设计软件界面 首先添加一个窗体,然后在添加一个按钮,作为空间查询点击的入口按钮然后新建一个查询窗体,并设计其界面34.2 进行代码的编写与调试 4.2.1 空间查询功能各个的实现 把窗体至于最上边:把窗体至于最上边:Public Declare Function SetWindowPos Lib “user32“ (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, By

4、Val X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPublic Const SWP_NOSIZE = &H1Public Const SWP_NOMOVE = &H2Public Const HWND_TOPMOST = -1Public Const HWND_NOTOPMOST = -2Public Recordset As MapObjects2.RecordsetPublic pSel As MapObjects2.RecordsetPublic

5、 pShape As Object画图查询功能:画图查询功能:Public Sub ExecuteSearch()If Not pShape Is Nothing Then SetpSel=Form1.Map1.Layers(frmSpatialQ.Combo1.ListIndex).SearchShape(pShape, frmSpatialQ.cboMethod.ListIndex, “)End IfEnd Sub查询显示属性表信息的功能:查询显示属性表信息的功能:Private Sub Command1_Click()Dim Rect As Rectangle, Rect2 As Rec

6、tangleDim shapeX As Double, shapeY As DoubleDim deltax As Double, deltay As DoubleDim theShape As Object, pinPoint As MapObjects2.PointDim i As IntegerDim recNo As IntegerrecNo = MSFlexGrid1.Row - 1pSel.MoveFirst记录指针移动到属性数据表选择中的记录上记录指针移动到属性数据表选择中的记录上For i = 0 To recNo - 1pSel.MoveNextNext i4Set theS

7、hape = pSel(“shape“).ValueIf pSel(“shape“).Type = moPoint ThenSet Rect2 = Form1.Map1.ExtentshapeX = pSel(“shape“).Value.XshapeY = pSel(“shape“).Value.Ydeltax = shapeX - Rect2.Center.Xdeltay = shapeY - Rect2.Center.YRect2.Offset deltax, deltayRect2.ScaleRectangle 0.1Form1.Map1.Extent = Rect2ElseSet R

8、ect = pSel(“shape“).Value.ExtentRect.ScaleRectangle 1.1Form1.Map1.Extent = RectEnd IfSet Rect2 = NothingSet theShape = NothingEnd Sub用表显示选中图形:用表显示选中图形:Public Sub DisplaySelFeature()If Not pSel Is Nothing ThenDim tDesc As MapObjects2.TableDescDim i As IntegerSet tDesc = pSel.TableDescDim recscount As

9、 Integer*以下代码用来填充以下代码用来填充 msgflexgridDim m As IntegerDim n As IntegerpSel.MoveFirstDo While Not pSel.EOFpSel.MoveNextrecscount = recscount + 1Loop MsgBox recsCountfrmSpatialQ.MSFlexGrid1.Cols = tDesc.FieldCount + 1frmSpatialQ.MSFlexGrid1.Rows = recscount + 1frmSpatialQ.MSFlexGrid1.AllowUserResizing

10、= flexResizeColumnsfrmSpatialQ.MSFlexGrid1.ClearfrmSpatialQ.MSFlexGrid1.CellAlignment = flexAlignLeftCenterFor i = 1 To tDesc.FieldCountfrmSpatialQ.MSFlexGrid1.ColWidth(i) = tDesc.FieldLength(i - 1) * 725Next ito filled the fields name into gridfrmSpatialQ.MSFlexGrid1.TextMatrix(0, 0) = “特征 ID“For i

11、 = 1 To recscountfrmSpatialQ.MSFlexGrid1.TextMatrix(i, 0) = ifrmSpatialQ.MSFlexGrid1.CellAlignment = flexAlignLeftCenterNext iFor i = 0 To tDesc.FieldCount - 1frmSpatialQ.MSFlexGrid1.TextMatrix(0, i + 1) = tDesc.FieldName(i)frmSpatialQ.MSFlexGrid1.ColAlignment(i) = flexAlignLeftCenterfrmSpatialQ.MSF

12、lexGrid1.ColWidth(i) = 1200Next ifrmSpatialQ.MSFlexGrid1.ColAlignment(0) = flexAlignCenterCenterfrmSpatialQ.MSFlexGrid1.ColWidth(0) = 680pSel.MoveFirstFor m = 1 To recscountFor n = 0 To tDesc.FieldCount - 1frmSpatialQ.MSFlexGrid1.TextMatrix(m, n + 1) = pSel.Fields(tDesc.FieldName(n).ValueNext npSel.

13、MoveNextNextpSel.MoveFirstfrmSpatialQ.MSFlexGrid1.RefreshEnd IfEnd Sub查询方式的调用:查询方式的调用:Private Sub Form_Load()SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZEDim layer As New MapObjects2.MapLayerFor Each layer In Form1.Map1.LayersCombo1.AddItem layer.NameNext layerCombo1.ListI

14、ndex = 0初始化空间搜索方法初始化空间搜索方法cboMethod.AddItem “重叠“6cboMethod.AddItem “有一个公共点“cboMethod.AddItem “边缘相交“cboMethod.AddItem “有一条公共边“cboMethod.AddItem “有公共点或边缘相交“cboMethod.AddItem “有交集“cboMethod.AddItem “内交“cboMethod.AddItem “内交,但边缘不相交“cboMethod.AddItem “特征包含形“cboMethod.AddItem “形包含特征“cboMethod.AddItem “特征完

15、全包含形“cboMethod.AddItem “形完全包含特征“cboMethod.AddItem “特征包含形的第一个点“cboMethod.AddItem “形包含特征的中心“cboMethod.AddItem “特征和形相同“cboMethod.ListIndex = 5End Sub画图功能:画图功能:Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)Dim pSymRecordset As New MapObjects2.SymbolDim pSymSel As New MapObjects2

16、.SymbolpSymSel.Color = moYellowpSymRecordset.Color = moRedIf Not pSel Is Nothing Then Map1.DrawShape pSel, pSymSelIf Not Recordset Is Nothing Then Map1.DrawShape Recordset, pSymRecordsetDim pSym As New MapObjects2.SymbolIf Not pRectangle Is Nothing ThenpSym.SymbolType = moFillSymbolpSym.Style = moTransparentFillpSym.OutlineColor = moRedMap1.DrawSh

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号