您好,欢迎访问三七文档
1实验报告GIS应用软件开发专业:测绘工程班级:10级测绘三班姓名:学号:指导教师:胡亚撰写时间:2013年5月20日星期一2目录一、程序运行演示...........................................................................................................................2二、问题及解决方案.......................................................................................................................6三、源程序代码...............................................................................................................................7四、心得体会.................................................................................................................................14一、程序运行演示1.新建项目文件,并实现file中的基本功能,显示地图基本要素。如图1图12.在工具栏加载按钮,按钮功能是对当前视图缩小3倍;在工具栏加载工具,工具功能在地图上标注当前日期。如图23图2按钮实现缩小3倍功能操作,如图3图33.点击地图节点,弹出如图4,图5菜单并实现菜单中的内容:图44图54.点击图层节点,弹出如图6菜单并需要实现菜单中的内容图65.点击LegendClass,弹出符号选择对话框,该对话框供用户按需要选择符号并进行更改。如图75图76.打开图层属性表,用户选择某条记录,可弹出如图8,9所示的右键菜单,并实现右键菜单中的内容6图8图9二、问题及解决方案问题1.VS2008与2010之间要进行格式转换,按照所导向的步骤进行,否则程序将无法正常运行,出现错误7问题2.构建好基本框架后,地图文档中要素显示出现问题。此问题要添加licence控件,否则无法显示地图要素。问题3.使用Toolbar和Toc功能时无法进行操作此问题应在属性设置时建立关联功能。问题4.程序Program文件中要添加相应功能键语句,否则将无法实现功能。问题5.引用接口,方法,例如ADF,要添加相应的引用,否则程序出现错误。问题6.在实现两个自定义按钮与工具时,遇到的问题:先直接引用现有项未实现,发现缺少一些东西,后自己直接创建的Basetool和Basecommand类;在代码中报错,重新生成解决方案后顺利解决这个问题。问题7.在实现地图和图层节点的右键功能时,遇到琐碎的问题,在这个过程中直接引用老师所给的几个类,但是报错,是因为命名空间未做修改;缺少引用,需要根据错误提示添加相应的引用三、源程序代码usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Runtime.InteropServices;usingESRI.ArcGIS.esriSystem;usingESRI.ArcGIS.Carto;usingESRI.ArcGIS.Controls;usingESRI.ArcGIS.ADF;usingESRI.ArcGIS.SystemUI;usingESRI.ArcGIS.Display;namespaceWindowsFormsApplication2{publicpartialclassMainForm:Form{#regionclassprivatemembers8privateIMapControl3m_mapControl=null;privatestringm_mapDocumentName=string.Empty;#endregionIMapDocumentm_MapDocument=newMapDocument();#regionclassconstructorprivateITOCControl2m_tocControl;privateIToolbarMenum_menuMap;privateIToolbarMenum_menuLayer;privateZoomIn3XCMD1test=newZoomIn3XCMD1();publicMainForm(){InitializeComponent();}privatevoidnewDocumentToolStripMenuItem_Click(objectsender,EventArgse){ICommandcommand=newCreateNewDocument();command.OnCreate(m_mapControl.Object);command.OnClick();}privatevoidopenDocumentToolStripMenuItem_Click(objectsender,EventArgse){openFileDialog1.Title=SaveMapDocumentAs;openFileDialog1.Filter=MapDocuments(*.mxd)|*.mxd;openFileDialog1.ShowDialog();stringsFilePath=openFileDialog1.FileName;if(axMapControl1.CheckMxFile(sFilePath)){axMapControl1.MousePointer=esriControlsMousePointer.esriPointerHourglass;axMapControl1.LoadMxFile(sFilePath,0,Type.Missing);axMapControl1.MousePointer=esriControlsMousePointer.esriPointerDefault;}else{MessageBox.Show(sFilePath+isnotavalidArcMapdocument);return;9}}privatevoidMainForm_Load(objectsender,EventArgse){//gettheMapControlm_mapControl=(IMapControl3)axMapControl1.Object;//disabletheSavemenu(sincethereisnodocumentyet)this.menuSaveDoc.Enabled=false;//定义地图右键菜单,图层右键菜单m_tocControl=(ITOCControl2)axTOCControl1.Object;m_mapControl=(IMapControl3)axMapControl1.Object;//添加菜单到地图节点m_menuMap=newToolbarMenu();m_menuMap.AddItem(esriControls.ControlsAdddataCommand,-1,0,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(newLayerVisibility(),1,1,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(newLayerVisibility(),2,2,false,esriCommandStyles.esriCommandStyleTextOnly);//添加菜单到图层节点m_menuLayer=newToolbarMenu();m_menuLayer.AddItem(newOpenAttributeTableCmd(),-1,0,false,esriCommandStyles.esriCommandStyleIconAndText);//右键添加属性表m_menuLayer.AddItem(newRemoveLayer(),1,1,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newRemoveLayer(),1,2,true,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newScaleThresholds(),2,3,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newScaleThresholds(),3,4,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newLayerSelectable(),1,5,true,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newLayerSelectable(),2,6,false,esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(newZoomToLayer(),-1,7,true,esriCommandStyles.esriCommandStyleTextOnly);10//Setthehookofeachmenum_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);}privatevoidsaveDocumentToolStripMenuItem_Click(objectsender,EventArgse){//executeSaveDocumentcommandif(m_mapControl.CheckMxFile(m_mapDocumentName)){//createanewinstanceofaMapDocumentIMapDocumentmapDoc=newMapDocument();mapDoc.Open(m_mapDocumentName,string.Empty);//MakesurethattheMapDocumentisnotreadonlyif(mapDoc.get_IsReadOnly(m_mapDocumentName)){MessageBox.Show(Mapdocumentisreadonly!);mapDoc.Close();return;}//ReplaceitscontentswiththecurrentmapmapDoc.ReplaceCont
本文标题:GIS实验报告
链接地址:https://www.777doc.com/doc-4741854 .html