GIS实验报告课件_第1页
GIS实验报告课件_第2页
GIS实验报告课件_第3页
GIS实验报告课件_第4页
GIS实验报告课件_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

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

文档简介

1、实验报告GIS应用软件开发专业:测绘工程班级:10级测绘三班姓名:学号:指导教师:胡一亚撰写时间:2021年5月20日星期一目录一、程序运行演示2二、问题及解决方案6三、源程序代码7四、心得体会14程序运行演示1.新建工程文件,并实现file中的根本功能,显示地图根本要素.如图1图12.在工具栏加载按钮,按钮功能是对当前视图缩小3倍;在工具栏加载工具,工具功能在地图上标注当前日期.如图2图2按钮实现缩小3倍功能操作,如图3图33.点击地图节点,弹出如图4,图5菜单并实现菜单中的内容:AddData.,所有图所不可见图54 .点击图层节点,弹出如图6菜单并需要实现菜单中的内容I-打"图

2、导一性表I去除当前图提SetMaximumScaleSetMinimumScaleLayerSelectable唱放子.三字交宴E重用c图65 .点击LegendClass,弹出符号选择对话框,该对话框供用户按需要选择符号并进行更改.如图7图76 .翻开图层属性表,用户选择某条记录,可弹出如图8,9所示的右键菜单,并实现右键菜单中的内容吧土地使用属性表FIDShapeAHEAPERIMETERcsriGtomtry.,35886.02737.53341esriGeofn9try.«2460644663.8805.esriGeometry,.4670,33351989623esriGc

3、ometry.».5768.605516.14094esriGeometry.,.4506,167493.5394sesriGeometry.38783.72777,4466esriGeovntry.429L706473.23957esriGeometry.,.6084.56250L77938esriGeometry,4337.143475.68389esriGeoffittry.1195874527.398910«sriGeometry.704L055470.680611esriGeometry.4481L19815.82351V&Lk(八K#*r口二加口0917

4、4图8图9问题及解决方案问题1.VS2021与2021之间要进行格式转换,根据所导向的步骤进行,否那么程序将无法正常运行,出现错误问题2.构建好根本框架后,地图文档中要素显示出现问题.此问题要添加licence控件,否那么无法显示地图要素.问题3.使用Toolbar和Toc功能时无法进行操作此问题应在属性设置时建立关联功能.问题4.程序Program文件中要添加相应功能键语句,否那么将无法实现功能.问题5.引用接口,方法,例如ADF,要添加相应的引用,否那么程序出现错误.问题6.在实现两个自定义按钮与工具时,遇到的问题:先直接引用现有项未实现,发现缺少一些东西,后自己直接创立的Basetool

5、和Basecomman嵬;在代码中报错,重新生成解决方案后顺利解决这个问题.问题7.在实现地图和图层节点的右键功能时,遇到琐碎的问题,在这个过程中直接引用老师所给的几个类,但是报错,是由于命名空间未做修改;缺少引用,需要根据错误提示添加相应的引用三、源程序代码usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;us

6、ingSystem.IO;usingSystem.Runtime.InteropServices;usingESRI.ArcGIS.esriSystem;usingESRI.ArcGIS.Carto;usingESRI.ArcGIS.Controls;usingESRI.ArcGIS.ADF;usingESRI.ArcGIS.SystemUI;usingESRI.ArcGIS.Display;namespaceWindowsFormsApplication2publicpartialclassMainForm:Form#regionclassprivatemembersprivateIMapC

7、ontrol3m_mapControl=null;privatestringm_mapDocumentName=string.Empty;#endregionIMapDocumentm_MapDocument=newMapDocument();#regionclassconstructorprivateITOCControl2m_tocControl;privateIToolbarMenum_menuMap;privateIToolbarMenum_menuLayer;privateZoomIn3XCMD1test=newZoomIn3XCMD1();publicMainForm()Initi

8、alizeComponent();privatevoidnewDocumentToolStripMenuItem_Click(objectsender,EventArgse)ICommandcommand=newCreateNewDocument();command.OnCreate(m_mapControl.Object);command.OnClick();privatevoidopenDocumentToolStripMenuItem_Click(objectsender,EventArgse)openFileDialog1.Title="SaveMapDocumentAs&q

9、uot;openFileDialog1.Filter="MapDocuments(*.mxd)|*.mxd"openFileDialog1.ShowDialog();stringsFilePath=openFileDialog1.FileName;if(axMapControl1.CheckMxFile(sFilePath)axMapControl1.MousePointeresriControlsMousePointer.esriPointerHourglass;axMapControl1.LoadMxFile(sFilePath,0,Type.Missing);axMa

10、pControl1.MousePointeresriControlsMousePointer.esriPointerDefault;elseMessageBox.Show(sFilePath+"isnotavalidArcMapdocument");return;privatevoidMainForm_Load(objectsender,EventArgse)/gettheMapControlm_mapControl=(IMapControl3)axMapControl1.Object;/disabletheSavemenu(sincethereisnodocumentye

11、t)this.menuSaveDoc.Enabled=false;/定义地图右键菜单,图层右键菜单m_tocControl=(ITOCControl2)axTOCControl1.Object;m_mapControl=(IMapControl3)axMapControl1.Object;/添加菜单到地图节点m_menuMap=newToolbarMenu();-1,0,false,m_menuMap.AddItem(newesriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(newLayerVisibility(),Lay

12、erVisibility(),1,2,1,2,false,false,esriCommandStyles.esriCommandStyleTextOnly);/添加菜单到图层节点m_menuLayer=newToolbarMenu();m_menuLayer.AddItem(newOpenAttributeTableCmd(),-1,0,false,esriCommandStyles.esriCommandStyleIconAndText);/m_menuLayer.AddItem(new右键添加属性表RemoveLayer(),1,1,false,esriCommandStyles.esri

13、CommandStyleTextOnly);m_menuLayer.AddItem(newesriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newRemoveLayer(),ScaleThresholds(),1,2,2,true,3,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newesriCommandStyles.esriCommandStyleTextOnly);ScaleThresholds(),3,4,fals

14、e,m_menuLayer.AddItem(newLayerSelectable(),1,5,true,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newLayerSelectable(),2,6,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newesriCommandStyles.esriCommandStyleTextOnly);ZoomToLayer(),-1,7,true,/Setthehookofeachm

15、enum_menuLayer.SetHook(m_mapControl);m_menuMap.SetHook(m_mapControl);axToolbarControl1.AddItem(test,-1,-1,true,0,esriCommandStyles.esriCommandStyleIconAndText);axToolbarControl1.AddItem(newAddDateTool(),-1,-1,false,0,esriCommandStyles.esriCommandStyleIconAndText);privatevoidsaveDocumentToolStripMenu

16、Item_Click(objectsender,EventArgse)/executeSaveDocumentcommandif(m_mapControl.CheckMxFile(m_mapDocumentName)m_menuMap.AddItem("esriControls.ControlsAdddataCommand",esriCommandStyles.esriCommandStyleTextOnly);/createanewinstanceofaMapDocumentIMapDocumentmapDoc=newMapDocument();mapDoc.Open(m

17、_mapDocumentName,string.Empty);/MakesurethattheMapDocumentisnotreadonlyif(mapDoc.get_IsReadOnly(m_mapDocumentName)(MessageBox.Show("Mapdocumentisreadonly!");mapDoc.Close();return;/ReplaceitscontentswiththecurrentmapmapDoc.ReplaceContents(IMxdContents)m_mapControl.Map);/savetheMapDocumentin

18、ordertopersistitmapDoc.Save(mapDoc.UsesRelativePaths,false);/closetheMapDocumentmapDoc.Close();#endregionprivatevoidsaveAsToolStripMenuItem_Click(objectsender,EventArgse)(/executeSaveAsDocumentcommandICommandcommand=newControlsSaveAsDocCommand();command.OnCreate(m_mapControl);command.OnClick();priva

19、tevoidexitToolStripMenuItem_Click(objectsender,EventArgse)(Application.Exit();sender,privatevoidaxMapControl1_OnMouseMove(objectIMapControlEvents2_OnMouseMoveEvente)(statusBarXY.Text=string.Format("0,12",e.mapX.ToString("#.#"),e.mapY.ToString("#.#"),axMapControl1.MapUni

20、ts.ToString().Substring(4);privatevoidaxMapControl1_OnMapReplaced(objectsender,IMapControlEvents2_OnMapReplacedEvente)添加两个工具时添加test.m_activeView=this.axMapControl1.ActiveView;/getthecurrentdocumentnamefromtheMapControlm_mapDocumentName=m_mapControl.DocumentFilename;/ifthereisnoMapDocument,diabletheS

21、avemenuandclearthestatusbarif(m_mapDocumentName=string.Empty)menuSaveDoc.Enabled=false;statusBarXY.Text=string.Empty;else/enabletheSavemanuandwritethedocnametothestatusbarmenuSaveDoc.Enabled=true;statusBarXY.Text=Path.GetFileName(m_mapDocumentName);sender,privatevoidaxTOCControl1_OnMouseDown(objectI

22、TOCControlEvents_OnMouseDownEvente)if(e.button=1)/IBasicMapmap=newMap();IMapMap=newMap();IBasicMapmap=(IBasicMap)Map;ILayerlayer=newFeatureLayer();objectother=newobject();objectindex=newobject();esriTOCControlItemitem=newesriTOCControlItem();/DeterminewhatkindofitemhasbeenclickedonaxTOCControl1.HitT

23、est(e.x,e.y,refitem,refmap,reflayer,refother,refindex);/QItoIFeatureLayerandIGeoFeatuerLayerinterfaceif(layer=null)return;IFeatureLayerfeatureLayer=layerasIFeatureLayer;if(featureLayer=null)return;IGeoFeatureLayergeoFeatureLayer=(IGeoFeatureLayer)featureLayer;ILegendClasslegendClass=newLegendClass()

24、;ISymbolsymbol=null;if(otherisILegendGroup&&(int)index!=-1)legendClass=(ILegendGroup)other).get_Class(int)index);symbol=legendClass.Symbol;if(symbol=null)return;symbol=GetSymbolByControl(symbol);/symbol=GetSymbolBySymbolSelector(symbol);if(symbol=null)return;legendClass.Symbol=symbol;this.Ac

25、tivate();/FirecontentschangedeventthattheTOCControllistenstoaxMapControl1.ActiveView.ContentsChanged();/RefreshthedisplayaxMapControl1.Refresh(esriViewDrawPhase.esriViewGeography,null,null);axTOCControl1.Update();if(e.button=2)esriTOCControlItemitem=esriTOCControlItem.esriTOCControlItemNone;IBasicMa

26、pmap=null;ILayerlayer=null;objectother=null;objectindex=null;/Determinewhatkindofitemisselectedm_tocControl.HitTest(e.x,e.y,refitem,refmap,reflayer,refother,refindex);/Ensuretheitemgetsselectedif(item=esriTOCControlItem.esriTOCControlItemMap)m_tocControl.SelectItem(map,null);elsem_tocControl.SelectI

27、tem(layer,null);/SetthelayerintotheCustomProperty(thisisusedbythecustomlayercommands)m_mapControl.CustomProperty=layer;/Popupthecorrectcontextmenuif(item=esriTOCControlItem.esriTOCControlItemMap)m_menuMap.PopupMenu(e.x,e.y,m_tocControl.hWnd);if(item=esriTOCControlItem.esriTOCControlItemLayer)m_menuLayer.PopupMenu(e.x,e.y,m_tocControl.hWnd);privateISymbolGetSymbolByControl(ISymbolsymbolType)ISymbolsymbol=null;IStyleGalleryItemstyleGalle

温馨提示

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

评论

0/150

提交评论