ArcGIS Engine基础实战.ppt_第1页
ArcGIS Engine基础实战.ppt_第2页
ArcGIS Engine基础实战.ppt_第3页
ArcGIS Engine基础实战.ppt_第4页
ArcGIS Engine基础实战.ppt_第5页
已阅读5页,还剩62页未读 继续免费阅读

下载本文档

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

文档简介

1、ArcGIS Engine基础介绍,Esri西安分公司 姚啸,介绍内容,ArcGIS Engine简介 创建第一个ArcGIS Engine程序 练习DEMO,ArcGIS Engeine简介,ArcGIS Engine Developer Kit,开发包是组件, APIs 和工具的集合 开发人员可以用来创建高级的 GIS 应用 组件 Engine 库 制图、绘制、选择、编辑等 Control 库 地图控件、布局控件、工具条等 APIs COM、.NET、Java、C+ 工具 文档、开发工具,ArcGIS Engine功能框架,基本服务 应用层需要用到的 ArcObjects 核心对象 几何图

2、形的操作与显示 数据访问 地理数据集,矢量,栅格数据 地图分析 属性、空间查询,地理数据处理 地图显示 渲染、标注、制图表达 开发组件 各种应用层面上的 Control 及 Commands layer.ShowTips = true;,ToolTip tootip1 = new ToolTip; tootip1.SetToolTip(axMapControl1,这是一个提示);,PageLayoutControl控件,PageLayoutControl 封装PageLayout coclass 绘制地图元素 创建版面视图 打印 设置当前工具 加载地图文档 库 PageLayoutContro

3、l.ocx,PageLayoutControl控件,使用PageLayout 来访问其它对象 Elements(例子代码 MapElements) FrameElements MapFrame MapSurroundFrame GraphicElements PictureElements,使用elements,关于elements有很多高级的成员函数 IPageLayoutControl AddElement FindElementByName LocateFrontElement GraphicsContainer,地图上显示查询结果element,查询结果的渲染,ISimpleMarke

4、rSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgb; simpleMarkerSymbol.Size = 30; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = (IElement)markerElement; element.Geometry = point; graphicsContainer

5、 = (IGraphicsContainer)map; graphicsContainer.AddElement(element, 0);,使用地图文档,MXD 文件是结构化的存储文档(保存路径) 通常由ArcMap创建 包含持久对象 Maps, Layers, PageLayout, MapDocument 使以下成为可能 读取 mxd, lyr, mxt, and pmf files 写新的 mxd files 访问map document的内容,IMapDocument与mxd,读取和写地图文档的成员函数 Open: 打开已经存在的地图文档 (mxd, mxt, lyr, pmf) Sa

6、veAs: 保存当前文档到新的文件 CheckMxFile:检查mxd是否存在 LoadMxFile:加载mxd文档 ReadMxMaps:读mxd文档 New:新建mxd文档 Save:保存mxd文档,加载mxd,LoadMxFile,if (openFileDialog2.ShowDialog() = DialogResult.OK) string FilePath = openFileDialog2.FileName; if (axMapControl1.CheckMxFile(FilePath) axMapControl1.MousePointer = ESRI.ArcGIS.Cont

7、rols.esriControlsMousePointer.esriPointerHourglass; axMapControl1.LoadMxFile(FilePath, 0, Type.Missing); axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerDefault; else MessageBox.Show(FilePath + is not a vaild ArcMap document); return; ,访问地图文档中的对象,控件可以直接引用对象 (Map

8、 and PageLayout) 或访问自己的拷贝 Reference 直接 Copy 使用ObjectCopy 避免共享引用 深度复制,IMapDocument mapdoc = new MapDocument(); axMapControl1.Map = mapdoc.get_Map(0) ;,IObjectCopy objectcopy = new ObjectCopyClass(); IPageLayout pagelayout = objectcopy.Copy(mapdoc.PageLayout) as IPageLayout;,框架控件,ToolbarControl 和 TOCC

9、ontrol 被设计成和其它控件协同工作 通过一个buddy控件自动捆绑在一起 根据彼此的状态通信和同步 例子: active tool, layer visibility,Buddy Control,Toolbar,TOC,命令和工具,提供超过 100 个工具和命令,TocControl,显示所有的图层和符号 Simple symbols, renderers Group layers 控制图层可视性 必须调用SetBuddyControl 库 TOCControl.ocx,ToolbarControl,自定义 commands, tools 和 menus的容器 允许命令和以下控件对象进行

10、交互 Map, PageLayout, Scene, 和 Globe 必须调用 SetBuddyControl 库 ToolbarControl.ocx,制图控件命令,系统提供的控件命令, 工具, 工具条, 和菜单 命令和工具 漫游, 缩放, 打开地图, 图形绘制, 工具条 要素选择, 绘图, 地图导航, 和 pagelayout 菜单 要素选择和地图浏览 库 esriCommandControls.olb 参考 对象模型图或技术文档,创建第一个ArcGIS Engeine应用程序,创建一个控件应用程序 使用控件成员 使用工具条和TOC控件 加载 MXD 文档 保存mxd文档 打开shp,开发

11、环境,COM Visual Studio 6.0 (VB、VC+)、Delphi ArcGIS Engine 10 不再支持 VB 6.0 .NET Visual Studio .NET (VB .NET、C#、VC+.NET) ArcGIS Engine 10.1 不支持VS2008 C+ Visual Studio 6.0、Borland C+ Builder、C+ Java JBuilder、Eclipse、JDK,开发环境,安装VS2012 安装ArcGIS SDK Developer Kit return; ,打开mxd,if (openFileDialog2.ShowDialog(

12、) = DialogResult.OK) string FilePath = openFileDialog2.FileName; if (axMapControl1.CheckMxFile(FilePath) axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerHourglass; axMapControl1.LoadMxFile(FilePath, 0, Type.Missing); axMapControl1.MousePointer = ESRI.ArcGIS.Cont

13、rols.esriControlsMousePointer.esriPointerDefault; else MessageBox.Show(FilePath + is not a vaild ArcMap document); return; ,打开shp,打开shp /axMapControl1.Map.ClearLayers(); IWorkspaceFactory pWorkspaceFactory; IFeatureWorkspace pFeatureWorkspace; IFeatureLayer pFeatureLayer; this.openFileDialog1.Filter

14、 = shp文件|*.shp; if (this.openFileDialog1.ShowDialog() = DialogResult.OK) this.textBox1.Text = this.openFileDialog1.FileName.ToString(); string strFullPath = openFileDialog1.FileName; if (strFullPath = ) return; int Index = strFullPath.LastIndexOf(); string filePath = strFullPath.Substring(0, Index);

15、 string fileName = strFullPath.Substring(Index + 1); /打开工作空间并添加shp文件 pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();/创建工作空间 pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0);/打开矢量数据所在的空间 pFeatureLayer = new FeatureLayerClass();/创建一个要素图层 pFeatureLayer.Featur

16、eClass = pFeatureWorkspace.OpenFeatureClass(fileName);/将要素类加如到要素图层 pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName;/将要素类的名称赋值给要素图层 axMapControl1.Map.AddLayer(pFeatureLayer);/将图层加到地图控件 axMapControl1.ActiveView.Refresh();/刷新地图,保存mxd,IMapDocument mapDoc4 = new MapDocumentClass(); mapDoc4.New(

17、F:/teuu5.mxd); IMxdContents mxdContents = axMapControl1.Map as IMxdContents; mapDoc4.ReplaceContents(mxdContents); mapDoc4.Save(false, true); mapDoc4.Close();,练习DEMO,打开数据源,打开gdb IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass(); workspace = workspaceFactory.OpenFromFile(“D:/dat

18、a.gdb”, 0); IFeatureWorkspace pFeatWorkspace = workspace as IFeatureWorkspace;IFeatureClass pFeatureClass = pFeatWorkspace.OpenFeatureClass(Water),打开sde IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty(SERVER, server); propertySet.SetProperty(INSTANCE, instance); propertySe

19、t.SetProperty(DATABASE, database); propertySet.SetProperty(USER, user); propertySet.SetProperty(PASSWORD, password); propertySet.SetProperty(VERSION, version); IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass(); workspace = workspaceFactory.Open(propertySet, 0);,属性查询,ILayer layer =

20、axMapControl1.get_Layer(0); IFeatureLayer featureLayer = layer as IFeatureLayer; /获取featureLayer的featureClass IFeatureClass featureClass = featureLayer.FeatureClass; IQueryFilter queryFilter = new QueryFilterClass(); IFeatureCursor featureCusor; string filter = DLMC = 旱地; queryFilter.WhereClause = f

21、ilter; featureCusor = featureClass.Search(queryFilter, true); if (featureCusor != null) IFeature fea = featureCusor.NextFeature(); while(fea != null) if (featureCusor = null) return; IGeometry geom = fea.Shape; IPolygon polygon = geom as IPolygon; Common.renderPolygon(polygon, axMapControl1.ActiveVi

22、ew, axMapControl1.Map); fea = featureCusor.NextFeature(); ,查询所有旱地,绘制多边形,IFillShapeElement pPolygonElement; ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); IPolygon pPolygon = new PolygonClass(); IRubberBand pRubberBand = new RubberPolygonClass(); ISimpleLineSymbol pSimpleLineSymbo

23、l = new SimpleLineSymbolClass(); pPolygonElement = new PolygonElementClass(); if (e.button = 1) pPolygon = (IPolygon)pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pSimpleLineSymbol.Color =

24、Common.GetRGBColor(46, 24, 63); pSimpleFillSymbol.Color = Common.GetRGBColor(11, 200, 145); pSimpleFillSymbol.Outline = pSimpleLineSymbol; IElement pElement = (IElement)pPolygonElement; pElement.Geometry = pPolygon; pPolygonElement.Symbol = pSimpleFillSymbol; IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.Map; pGraphicsContainer.AddElement(IElement)pPolygonElement, 0); axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);,地图点击绘制

温馨提示

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

评论

0/150

提交评论