您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 基于visual c#arcEngine9.2地理信息系统开发
1基于visualc#/arcEngine9.2地理信息系统开发[b]在介绍基于visualc#/arcEngine9.2地理信息系统开发之前,强调几个问题:[/b]1,RS与GIS的关系:遥感即遥远的感知,是对被探测目标物的谱线来获取其物理,化学,生物等属性特征和空间特征,遥感影像进入实践必须经过地理编码,成为栅格影像进入GIS系统,以实现GIS的各种功能提供数据源。RS的侧重点在于RS影像的处理已达到某种期望值,GIS则侧重在于汇聚的各种数据进行管理,分析和发布。因此RS和GIS一般来讲都不应该被分割,当然他们属于两个独立的体系。2,由于AE开发本质上是COM组建搭建,相对底层开发要简单许多,但目前国内的参考数据较少,限制了很多人的进一步学习,因此,希望在这个平台给大家具体介绍ArcEnine开发的相关知识,也作为自己在研究生生涯的一次检验吧。3,希望在介绍完AE开发后,有时间跟大家分享如何利用Visualc++/MFC处理图像和图形设计,包括VTK,OpenGL,OpenCV.[b]开发环境:[/b]windowxp,visualstodio2005,arcengineruntime9.2(或者安装有arcgisdesktop9.2),arcenginedevelopkit9.2本次作为训练的第一讲,给大家综合的介绍一下AE开发,以下的代码都通过VC2005编译通过。[b]功能设计:[/b]1,加载地图,图层,shp文件2,(另)保存地图,删除图层3,地图基本操作4,绘制图形5,选择元素6,。。。[b]界面设计:[/b][b]具体开发步骤:[/b]1.1建立基于c#的windowapplication.(略)[b][color=red]1.2加载地图:[/color][/b]privatevoidLoaddocument(){//addmapSystem.Windows.Forms.OpenFileDialogopenFiledialog;openFiledialog=newOpenFileDialog();openFiledialog.Title=OpenFileDilogHere;openFiledialog.Filter=mapdocument(*.mxd)|*.mxd;openFiledialog.ShowDialog();2stringfilepath=openFiledialog.FileName;if(axMapControl1.CheckMxFile(filepath)){axMapControl1.MousePointer=esriControlsMousePointer.esriPointerHourglass;axMapControl1.LoadMxFile(filepath,0,Type.Missing);axMapControl1.MousePointer=esriControlsMousePointer.esriPointerDefault;}else{MessageBox.Show(filepath+cannotopen);}}当然也可以在工具箱中拖入一个openfiledialog控件,上述函数也可以写成:privatevoidLoaddocument2(){//addspeciallymapSystem.Windows.Forms.OpenFileDialogopenFiledialog;openFiledialog=newOpenFileDialog();openFiledialog.Title=OpenFileDilogHere;//openFiledialog.Filter=AllFiles(*.mxd)|*.mxd;openFiledialog.Filter=mapdocument(*.mxd)|*.mxd;openFiledialog.ShowDialog();stringfilepath=openFiledialog.FileName;if(axMapControl1.CheckMxFile(filepath)){IArrayarraymap=axMapControl1.ReadMxMaps(filepath,Type.Missing);inti;IMapmap;for(i=0;iarraymap.Count;i++){map=arraymap.get_Element(i)asIMap;if(map.Name==Layers){axMapControl1.MousePointer=esriControlsMousePointer.esriPointerHourglass;axMapControl1.LoadMxFile(filepath,0,Type.Missing);axMapControl1.MousePointer=esriControlsMousePointer.esriPointerDefault;}}3}else{MessageBox.Show(filepath+cannotopen);}}1.3加载图层privatevoidaddlayerfile(){System.Windows.Forms.OpenFileDialogopenlayerfile;openlayerfile=newOpenFileDialog();openlayerfile.Title=openlayerfile;openlayerfile.Filter=Layerfile(*.lyr)|*.lyr;openlayerfile.ShowDialog();stringfilepath=openlayerfile.FileName;try{axMapControl1.AddLayerFromFile(filepath,0);}catch(System.Exceptionex){MessageBox.Show(filepath+cannotopen+ex.ToString());}}1.4加载SHP文件:privatevoidaddshpfile(){System.Windows.Forms.OpenFileDialogopenlayerfile;openlayerfile=newOpenFileDialog();openlayerfile.Title=openlayerfile;openlayerfile.Filter=Layerfile(*.shp)|*.shp;openlayerfile.ShowDialog();FileInfofileinfo=newFileInfo(openlayerfile.FileName);stringfilepath=openlayerfile.FileName.Substring(0,openlayerfile.FileName.Length-fileinfo.Name.Length);try{axMapControl1.AddShapeFile(filepath,fileinfo.Name);}catch(System.Exceptionex){MessageBox.Show(filepath+cannotopen+ex.ToString());4}}1.5删除图层:privatevoiddeletelayer(){try{for(inti=axMapControl1.LayerCount-1;i=0;i--){axMapControl1.DeleteLayer(i);}}catch(System.Exceptionex){MessageBox.Show(deletelayerfailed+ex.ToString());}}1.6移动图层:privatevoidmovelayer(){if(axMapControl1.LayerCount0){try{axMapControl1.MoveLayerTo(axMapControl1.LayerCount-1,0);}catch(System.Exceptionex){MessageBox.Show(cannotmovethelayer+ex.ToString());}}}1.7保存文档:privatevoidsavedocument(){if(mapdocument.get_IsReadOnly(mapdocument.DocumentFilename)==true){MessageBox.Show(mapdocument.DocumentFilename+isreadonly);5}System.Windows.Forms.OpenFileDialogsavedialog;savedialog=newOpenFileDialog();savedialog.Title=savemapdocument;savedialog.CheckFileExists=true;savedialog.CheckPathExists=true;savedialog.DefaultExt=mxd;savedialog.ShowDialog();stringstrsavepath=savedialog.FileName;try{//mapdocument.Save(mapdocument.UsesRelativePaths,true);mapdocument.Save(false,true);}catch(System.Exceptionex){MessageBox.Show(savemapdocumentfailed+ex.ToString());}}1.8另存为文档:privatevoidsaveasdocment(){if(mapdocument.get_IsReadOnly(mapdocument.DocumentFilename)==true){MessageBox.Show(mapdocument.DocumentFilename+isreadonly);}System.Windows.Forms.OpenFileDialogsavedialog;savedialog=newOpenFileDialog();savedialog.Title=savemapdocument;savedialog.CheckFileExists=true;savedialog.CheckPathExists=true;savedialog.DefaultExt=mxd;savedialog.ShowDialog();stringstrsavepath=savedialog.FileName;try{mapdocument.SaveAs(strsavepath,true,true);}catch(System.Exceptionex){MessageBox.Show(savemapdocumentfailed+ex.ToString());6}}2地图的基本操作采用统一的格式对其进行处理,在类中定义一个变量,用以标记操作的类型。privateintnOperator=-1;//地图操作对其进行设计如下:nOperator=1表明为:zoominnOperator=2表明为:zoomoutnOperator=3表明为:pannOperator=4表明为:drawpolylinenOperator=5表明为:drawcirclenOperator=6表明为:drawrectnOperator=7表明为:drawpolygonnOperator=8表明为:drawtext/*预留备用*/nOperator=10表明为:pointselectnOperator=11表明为:circleselectnOperator=12表明为:rectselectnOperator=13表明为:polygonselectnOperator=14表明为:basenameselectnOperator=15表明为:deleteselection..
本文标题:基于visual c#arcEngine9.2地理信息系统开发
链接地址:https://www.777doc.com/doc-3372663 .html