mapobjects实验_第1页
mapobjects实验_第2页
mapobjects实验_第3页
mapobjects实验_第4页
mapobjects实验_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

本科学生验证性实验报告姓名 查建勋 学号 104130101专业 GIS 班级 10地信 实验课程名称 GIS设计与开发 指导教师及职称 彭双云 开课学期 2013 至 2014 学年 第一 学期上课时间 2013 年 10 月 9 日云南师范大学旅游与地理科学学院地理信息系统系一、实验设计实验名称:SearchByDistance和SearchShape联合空间数据查询功能的实现实验时间:2013-11-19小组合作:是()否()小组成员:无1、 实验内容(含实验原理介绍):1.1设计软件界面和添加需要的空间1.2进行编程并进行调试1.3对程序进行优化并进行调试1.4实现如下界面功能功能解析:1.4.1能够通过绘制点线面等图形,基于MO提供的空间关系进行查询,并显示查询结果;1.4.2能够根据图上选择的地理要素,基于MO提供的空间关系进行查询,并显示查询结果;1.4.3根据查询出来的结果进行空间定位与显示。2、 实验目的:学会使用SearchByDistance和SearchShape方法,能利用这两种方法进行空间查询,并将查询结果进行显示,根据查询记录定位、显示相关的地理要素。3、 设计实验相关情况介绍(包含使用软件以及实验设备等):(1)使用软件:MO软件和VB软件(2)实验设备:计算机、Windowsxp系统、4、 实验过程、方法步骤: 4.1设计软件界面首先添加一个窗体,然后在添加一个按钮,作为空间查询点击的入口按钮然后新建一个查询窗体,并设计其界面4.2进行代码的编写与调试4.2.1空间查询功能各个的实现把窗体至于最上边:Public Declare Function SetWindowPos Lib user32 (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal 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 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 Rectangle Dim shapeX As Double, shapeY As Double Dim deltax As Double, deltay As Double Dim theShape As Object, pinPoint As MapObjects2.Point Dim i As Integer Dim recNo As Integer recNo = MSFlexGrid1.Row - 1 pSel.MoveFirst 记录指针移动到属性数据表选择中的记录上 For i = 0 To recNo - 1 pSel.MoveNext Next i Set theShape = pSel(shape).Value If pSel(shape).Type = moPoint Then Set Rect2 = Form1.Map1.Extent shapeX = pSel(shape).Value.X shapeY = pSel(shape).Value.Y deltax = shapeX - Rect2.Center.X deltay = shapeY - Rect2.Center.Y Rect2.Offset deltax, deltay Rect2.ScaleRectangle 0.1 Form1.Map1.Extent = Rect2 Else Set Rect = pSel(shape).Value.Extent Rect.ScaleRectangle 1.1 Form1.Map1.Extent = Rect End If Set Rect2 = Nothing Set theShape = NothingEnd Sub用表显示选中图形:Public Sub DisplaySelFeature() If Not pSel Is Nothing Then Dim tDesc As MapObjects2.TableDesc Dim i As Integer Set tDesc = pSel.TableDesc Dim recscount As Integer * 以下代码用来填充msgflexgrid Dim m As Integer Dim n As Integer pSel.MoveFirst Do While Not pSel.EOF pSel.MoveNext recscount = recscount + 1 Loop MsgBox recsCount frmSpatialQ.MSFlexGrid1.Cols = tDesc.FieldCount + 1 frmSpatialQ.MSFlexGrid1.Rows = recscount + 1 frmSpatialQ.MSFlexGrid1.AllowUserResizing = flexResizeColumns frmSpatialQ.MSFlexGrid1.Clear frmSpatialQ.MSFlexGrid1.CellAlignment = flexAlignLeftCenter For i = 1 To tDesc.FieldCount frmSpatialQ.MSFlexGrid1.ColWidth(i) = tDesc.FieldLength(i - 1) * 72 Next i to filled the fields name into grid frmSpatialQ.MSFlexGrid1.TextMatrix(0, 0) = 特征 ID For i = 1 To recscount frmSpatialQ.MSFlexGrid1.TextMatrix(i, 0) = i frmSpatialQ.MSFlexGrid1.CellAlignment = flexAlignLeftCenter Next i For i = 0 To tDesc.FieldCount - 1 frmSpatialQ.MSFlexGrid1.TextMatrix(0, i + 1) = tDesc.FieldName(i) frmSpatialQ.MSFlexGrid1.ColAlignment(i) = flexAlignLeftCenter frmSpatialQ.MSFlexGrid1.ColWidth(i) = 1200 Next i frmSpatialQ.MSFlexGrid1.ColAlignment(0) = flexAlignCenterCenter frmSpatialQ.MSFlexGrid1.ColWidth(0) = 680 pSel.MoveFirst For m = 1 To recscount For n = 0 To tDesc.FieldCount - 1 frmSpatialQ.MSFlexGrid1.TextMatrix(m, n + 1) = pSel.Fields(tDesc.FieldName(n).Value Next n pSel.MoveNext Next pSel.MoveFirst frmSpatialQ.MSFlexGrid1.Refresh End IfEnd Sub查询方式的调用:Private Sub Form_Load() SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Dim layer As New MapObjects2.MapLayer For Each layer In Form1.Map1.Layers Combo1.AddItem layer.Name Next layer Combo1.ListIndex = 0 初始化空间搜索方法 cboMethod.AddItem 重叠 cboMethod.AddItem 有一个公共点 cboMethod.AddItem 边缘相交 cboMethod.AddItem 有一条公共边 cboMethod.AddItem 有公共点或边缘相交 cboMethod.AddItem 有交集 cboMethod.AddItem 内交 cboMethod.AddItem 内交,但边缘不相交 cboMethod.AddItem 特征包含形 cboMethod.AddItem 形包含特征 cboMethod.AddItem 特征完全包含形 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.Symbol Dim pSymSel As New MapObjects2.Symbol pSymSel.Color = moYellow pSymRecordset.Color = moRed If Not pSel Is Nothing Then Map1.DrawShape pSel, pSymSel If Not Recordset Is Nothing Then Map1.DrawShape Recordset, pSymRecordset Dim pSym As New MapObjects2.Symbol If Not pRectangle Is Nothing Then pSym.SymbolType = moFillSymbol pSym.Style = moTransparentFill pSym.OutlineColor = moRed Map1.DrawShape pRectangle, pSym End If If Not pPolygon Is Nothing Then pSym.SymbolType = moFillSymbol pSym.Style = moTransparentFill pSym.OutlineColor = moRed Map1.DrawShape pPolygon, pSym End IfEnd Sub点击鼠标后查询结果的显示:Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If frmSpatialQ.Toolbar1.Buttons(1).Value = tbrPressed Then Set pt = Map1.ToMapPoint(X, Y) Set pShape = pt ExecuteSearch DisplaySelFeature ElseIf frmSpatialQ.Toolbar1.Buttons(2).Value = tbrPressed Then Set pLine = Map1.TrackLine Set pShape = pLine ExecuteSearch DisplaySelFeature ElseIf frmSpatialQ.Toolbar1.Buttons(3).Value = tbrPressed Then Set pRectangle = Map1.TrackRectangle Set pShape = pRectangle ExecuteSearch DisplaySelFeature ElseIf frmSpatialQ.Toolbar1.Buttons(4).Value = tbrPressed Then Set pPolygon = Map1.TrackPolygon Set pShape = pPolygon ExecuteSearch DisplaySelFeature ElseIf frmSpatialQ.Toolbar1.Buttons(6).V

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论