已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
基于VB.NET与ArcEngine开发的地理信息系统ArcEngine程序设计实验报告学号:200725809 姓名:阙泽胜 专业方向:GIS设计与开发一、实验要求利用ArcEngine组件,结合VB或.NET开发环境,设计并实现一个小型GIS系统。1)使用控件要求:MapControl,ToolBarControl,TocControl等2)系统的功能模块1. 文件:打开、保存、退出2. 插入:文本、点、线、面、CAD、表、指北针、图例、图片3. 常用工具:选择、取消选择、放大、移图4. 专题制图:单值渲染、分级渲染、图表渲染5. 视图方式:地图视图、页面视图、场景视图、Global视图、鹰眼视图(导航图)其他功能:编辑表,查询等3)参考数据:WorldData文件中的World.mxd、dj-lu.dwg图、如琴湖.jpg和myDB. mdb。二、实验步骤及结果1.搭建系统框架,实现基本功能系统主界面采用如下架构,上面部分为菜单条和工具条,左面部分为图层管理,中间部分为MapControl控件,右边上面为鹰眼导航图,下边为选择查询功能见图2-1图2-12.关键功能实现(1) 加载CAD图CAD文件的加载有两种形式:一是要素图层,即以矢量数据的方式加载,二是栅格图层,即以栅格数据方式加载,以作背景图层使用。如下图2-2所示:实现思路:1) 窗体Load事件中加载:将地图从AxMapControl1复制到AxMapControl2。首先,将待复制的Imap图传递给pMap;其次结合FOR循环和pMap.LayerCount ,调用AxMapControl2.Map.AddLayer(pMap.Layer(i)实现图层复制. Private Sub AxMapControl1_OnMapReplaced(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent) Handles AxMapControl1.OnMapReplaced Dim pmap As IMap pmap = AxMapControl1.Map Dim i As Integer For i = pmap.LayerCount - 1 To i = 0 Step -1 AxMapControl3.Map.AddLayer(pmap.Layer(i) Next okBtn.SetBuddyControl(AxMapControl1) AxMapControl1.Refresh() AxMapControl3.Refresh() End Sub2)AxMapControl1_OnExtentUpdated事件,即当AxMapControl1的范围改变时的事件:1),定义Ienvelope变量目的是获取矩形坐标;2)用IgraphicsContainer定义容器,并将AxMapControl2.Map赋值给它,同时. DeleteAllElements()删除里面的所以元素;3)用IrectangleElement定义矩形元素并定义Ielement变量用QI传递矩形元素给它,并将定义好的Ienvelope变量传递给定义好的Ielement变量的.Geometry属性以便获取矩形坐标。4)用IrgbColo设置矩形的边线颜色。5)用IlineSymbol设置边线样式,包括Width,Color,Transparency。6)用IfillSymbol设置填充符号的属性,其.Colo,.OutLine有IrgbColo和IlineSymbol定义的变量得到。7)定义IfillShapeElement,用QI将Ielement定义的变量传递给它。其.Symbol属性由IfillSymbol定义的变量得到。8)使用容器的AddElement方法,传递参数为IfillShapeElement定义的变量。9)将容器QI给IactiveView定义的变量,并刷新它即可。Private Sub AxMapControl1_OnExtentUpdated(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent) Handles AxMapControl1.OnExtentUpdated Dim pEnv As IEnvelope pEnv = e.newEnvelope Dim pGra As IGraphicsContainer Dim pAc As IActiveView pGra = AxMapControl3.Map pAc = pGra pGra.DeleteAllElements() 获取矩形坐标() Dim pRec As IRectangleElement pRec = New RectangleElement Dim pEle As IElement pEle = pRec pEle.Geometry = pEnv 设置矩形的边线颜色() Dim pColor As IRgbColor pColor = New RgbColor pColor.RGB = RGB(255, 0, 0) Dim pOutLine As ILineSymbol pOutLine = New SimpleLineSymbol pOutLine.Width = 1.0 pOutLine.Color = pColor pColor = New RgbColor pColor.RGB = RGB(255, 0, 0) pColor.Transparency = 0 设置填充符号的属性() Dim pFillSymbol As IFillSymbol pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = pColor pFillSymbol.Outline = pOutLine Dim pFillShapeEle As IFillShapeElement pFillShapeEle = pEle pFillShapeEle.Symbol = pFillSymbol pGra.AddElement(pFillShapeEle, 0) pAc.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing) End Sub3)在AxMapControl2_OnMouseDown事件中加载:在AxMapControl2中跟踪一个矩形,通过定义接口Ienvelope变量将改矩形赋值给AxMapControl1的边界Extent,最后AxMapControl1刷新即可。Private Sub AxMapControl3_OnMouseDown_1(ByVal sender As System.Object, ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent) Handles AxMapControl3.OnMouseDown 拷贝map1到map2 Dim pMap As IMap pMap = AxMapControl1.Map Dim i As Integer For i = 0 To pMap.LayerCount - 1 AxMapControl3.Map.AddLayer(pMap.Layer(i) Next Dim pEnv As IEnvelope pEnv = AxMapControl3.TrackRectangle() AxMapControl1.Extent = pEnv AxMapControl1.Refresh()End Sub(2)设计属性查询结合VB.NET的模块和ArcEngineD模块设计如下:图2-3具体的实现如下:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 选择查询OkButton1.ClickAxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)Dim pFeaturlayer As IFeatureLayerpFeaturlayer = AxMapControl1.Map.Layer(0)Dim strFilter = CONTINENT= + searchComboBox2.Text().Trim() + searchSelection(strFilter, pFeaturlayer)End Sub(3)专题图表达的实现包括单值渲染、分级渲染、图表渲染三种方式。1)单值渲染如下效果:图2-4具体实现如下:Private Sub 简单渲染ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 简单渲染ToolStripMenuItem.Click Dim pGeoLayer As IFeatureLayer pGeoLayer = AxMapControl1.Map.Layer(1) Dim pGFLayer As IGeoFeatureLayer pGFLayer = pGeoLayer 新建一个填充符号 Dim pSimpleFillSym As ISimpleFillSymbol pSimpleFillSym = New SimpleFillSymbol pSimpleFillSym.Color = getRGB(0, 0, 255) pSimpleFillSym.Style = esriSimpleFillStyle.esriSFSSolid 新建一个SimpleRender对象 Dim pSimpleRender As ISimpleRenderer pSimpleRender = New SimpleRenderer With pSimpleRender .Symbol = pSimpleFillSym .Description = USA .Label = simpleFillRender End With Dim pTransRender As ITransparencyRenderer pTransRender = pSimpleRender pTransRender.TransparencyField = CONTINATE pGFLayer.Renderer = pSimpleRender AxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Nothing, Nothing) AxTOCControl1.Update()End SubSub SetClassBreakRender(ByVal pGFLayer As IGeoFeatureLayer, ByVal fieldName As String) 创建ClassBreakRender Dim pCBReader As IClassBreaksRenderer pCBReader = New ClassBreaksRenderer 获取该字段的最大值、最小值 Dim max, min As Long max = ComputeFieldValue(pGFLayer, fieldName, 1) min = ComputeFieldValue(pGFLayer, fieldName, 3) 设置分级数,字段, pCBReader.MinimumBreak = min pCBReader.Field = fieldName pCBReader.BreakCount = 4 设置每一级,分段范围,符号 Dim pFillSymbol As ISimpleFillSymbol pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(125, 0, 0) pCBReader.Break(0) = (max - min) / 4 + min pCBReader.Symbol(0) = pFillSymbol 设置每一级,分段范围,符号 pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(0, 125, 0) pCBReader.Break(1) = (max - min) * 2 / 4 + min pCBReader.Symbol(1) = pFillSymbol 设置每一级,分段范围,符号 pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(0, 0, 125) pCBReader.Break(2) = (max - min) * 3 / 4 + min 设置每一级,分段范围,符号pCBReader.Symbol(2) = pFillSymbol pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(0, 0, 250) pCBReader.Break(3) = max pCBReader.Symbol(3) = pFillSymbol pGFLayer.Renderer = pCBReader AxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Nothing, Nothing) End Sub Function ComputeFieldValue(ByVal pGFLayer As IGeoFeatureLayer, ByVal fieldName As String, ByVal state As Integer) As Double Dim pTable As ITable pTable = pGFLayer Dim pCursor As ICursor pCursor = pTable.Search(Nothing, True) Dim pDataStatics As IDataStatistics Dim pSResults As IStatisticsResults pDataStatics = New DataStatistics pDataStatics.Cursor = pCursor pDataStatics.Field = fieldName pSResults = pDataStatics.Statistics Dim Value As Double Select Case state Case 0 Value = pSResults.Count Case 1 Value = pSResults.Maximum Case 2 Value = pSResults.Mean Case 3 Value = pSResults.Minimum Case 4 Value = pSResults.Sum End Select Return Value End Function2) 分级渲染效果如下图:图2-5具体实现如下: Private Sub 分级渲染ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 分级渲染ToolStripMenuItem.Click Dim fieldName As String = Cnt_CONTIN Dim pGeoLayer As IFeatureLayer pGeoLayer = AxMapControl1.Map.Layer(0) Dim pGFLayer As IGeoFeatureLayer pGFLayer = pGeoLayer SetClassBreakRender(pGFLayer, fieldName)End Sub3) 图表渲染效果如下:图2-6具体实现如下:Private Sub 图表渲染ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 图表渲染ToolStripMenuItem.Click Dim fieldName1 As String = Cnt_CONTIN Dim fieldName2 As String = CityNumber Dim pGeoLayer As IFeatureLayer pGeoLayer = AxMapControl1.Map.Layer(0) Dim pGFLayer As IGeoFeatureLayer pGFLayer = pGeoLayer SetBarChartRender(pGeoLayer, fieldName1, fieldName2) End Sub Sub SetBarChartRender(ByVal pGFLayer As IGeoFeatureLayer, ByVal fieldName1 As String, ByVal fieldName2 As String) Dim pBarChartSymbol As IBarChartSymbol Dim pFillSymbol As IFillSymbol Dim pMarkerSymbol As IMarkerSymbol Dim pSymbolArray As ISymbolArray Dim pChartSymbol As IChartSymbol Dim pChartRenderer As IChartRenderer Dim pRendererFields As IRendererFields pBarChartSymbol = New BarChartSymbol 创建柱状符号 pBarChartSymbol.Width = 6 设置柱状符号的宽度,以象素为单位 获得pMarkerSymbol ,pChartSymbol 符号接口 pMarkerSymbol = pBarChartSymbol pChartSymbol = pBarChartSymbol 获取两个字段的最大值 Dim max, max1, max2 As Double max1 = ComputeFieldValue(pGFLayer, fieldName1, 1) max2 = ComputeFieldValue(pGFLayer, fieldName2, 1) If (max2 max1) Then : max = max2 Else : max = max1 End If 设置ChartSymbol的最大值,以及符号尺寸最大值(象素单位) pChartSymbol.MaxValue = max pMarkerSymbol.Size = 60 依据柱状符号,获得符号数组接口,设置第一个柱状图的符号。 pSymbolArray = pBarChartSymbol pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(213, 212, 252) pastel green pSymbolArray.AddSymbol(pFillSymbol) 设置第二个柱状图的符号 pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(193, 252, 179) pastel purple pSymbolArray.AddSymbol(pFillSymbol) 创建ChartRenderer接口 pChartRenderer = New ChartRenderer 设置ChartRenderer中的字段,依据这两个字段的数据值,创建柱状图 pRendererFields = pChartRenderer pRendererFields.AddField(fieldName1) pRendererFields.AddField(fieldName2) 将pBarChartSymbol 赋值给pChartRenderer的属性 pChartRenderer.ChartSymbol = pBarChartSymbol 设置图层的背景颜色 pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = getRGB(239, 228, 190) pChartRenderer.BaseSymbol = pFillSymbol 设置ChartRenderer的其他属性 pChartRenderer.UseOverposter = False pChartRenderer.CreateLegend() 创建符号图例 pChartRenderer.Label = Population by Gender pGFLayer.Renderer = pChartRenderer AxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, Nothing, Nothing)End Sub(4)插入文本设计的界面效果如下:图2-6具体实现如下:Private Sub AxMapControl1_MouseDown(ByVal sender As System.Object, ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent) Handles AxMapControl1.OnMouseDownIf m_CurOper = CurrentOper.AddText Then Dim mapX As Double Dim mapY As Double mapX = e.mapX mapY = e.mapYAddText(mapX, mapY)End Sub(5)插入指北针和图例效果如下:图2-8具体实现如下:Private Sub AxPageLayoutControl1_OnMouseDown(ByVal sender As System.Object, ByVal e As ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent) Handles AxPageLayoutControl1.OnMouseDown If m_CurOper = CurrentOper.DrawLegend Then Dim pEnv As IEnvelope pEnv = AxPageLayoutControl1.TrackRectangle() AddMapSurrounds_Legend(pEnv) AxPageLayoutControl1.Refresh() End If If m_CurOper = CurrentOper.DrawNorthArrow Then Dim pEnv As IEnvelope pEnv = AxPageLayoutControl1.TrackRectangle() AddMapSurrounds_NorthArrow(pEnv) AxPageLayoutControl1.Refresh() End If End SubPublic Sub AddMapSurrounds_N
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 北京市建筑工程施工劳务合同
- 山西省2024八年级物理上册第三章物态变化专题训练6.综合认识物态变化课件新版新人教版
- 湖北省十堰市2024-2025学年高一上学期11月期中物理试题(无答案)
- 矿山应急演练指南解读
- 广东省汕尾市海丰县附城中学2024-2025学年七年级上学期11月期中英语试题(含答案)
- 肿瘤科介入治疗及护理
- 耐辐照电绝缘玻璃纤维相关行业投资方案范本
- 工控电源相关行业投资方案范本
- 贵金属:铂行业相关投资计划提议
- 防汛应急方案培训
- 中国石化刮刮卡合同范例
- 认识他人课件教学课件
- 江苏省南通市2024-2025学年八年级上学期11月期中数学试题(无答案)
- 家装瓷砖铺贴专项施工协议范本
- 天津市2024年七年级上学期数学期中考试试卷【附答案】
- GB/T 17395-2024钢管尺寸、外形、重量及允许偏差
- 中国汽车刹车盘行业投资分析、市场运行态势研究报告-智研咨询发布
- “双减”政策下作业设计策略4篇
- 普外科重点专科评审工作汇报
- 期中阶段测试卷(试题)2024-2025学年统编版语文五年级上册
- 2023年中央机关遴选笔试真题及解析(B卷)
评论
0/150
提交评论