东华理工GIS二次开发实验报告(新)

合集下载

GIS二次开发程序设计

GIS二次开发程序设计

成绩批阅日期重庆交通大学测量与空间信息处理实验报告实验课程:GIS二次开发程序设计实验名称: GIS二次开发班级:学号:姓名:实验日期: 2012 年 6 月 25 日实验一界面设计一、实验目的和要求1、学会对MO进行安装。

2、熟悉Visual Basic和Map Object程序的基本操作。

3、掌握toolbar的操作步骤。

4、设置GIS二次开发的界面,要求界面具有菜单、工具条及设计程序时用到的各种控件等。

二、实验内容1、利用Visual Basic相应控件和操作以及Map Object完成界面设计,运用所安装的MO的控件进行所需界面设计。

2、在设计的界面上一次添加菜单、工具条、图例控件、map控件、状态栏等,并熟练掌握其操作步骤。

三、实验步骤1、在有MO和VB的环境中进行所设计的界面设计。

1)菜单的设计。

要求具有一些常用的功能。

如下图所示:2、对toolbar进行设计。

在菜单栏下面进行插入Button按钮,并在按钮上插入相应图像。

步骤如下图:3、插入map、legend、status等控件,并调整其大小。

得到最后成果图如下图所示:四、实验总结4.1、实验中遇到的困难在进行界面设计时,会遇到一些意想不到的困难,比如在插入toolbar 中的Button时,如果没有加入imagelist控件时,就不能在Button上插入图像。

还有在进行菜单操作时,有时会因为空格运行不当,而不能得到理想的下拉菜单。

4.2、处理方法和技巧在进行设计时,一定要记住操作的先后顺序,不然不能不到效果。

插入map 和legend等控件时,适当调节其大小,使界面更美观。

4.3、经验体会和收获刚开始做实验时感觉好难,不知怎么下手,可在完成这几次实验后我熟悉了MO的最基本功能,发现用VB对GIS进行二次开发没有想象中的那么难,但关于控件的问题很多,而且大家都不是很懂,只能多多交流,从网上搜素相关资料。

现如今地理信息系统的应用越来越广发,对它进行二次开发可以更大的发挥此软件的功能。

GIS二次开发实验报告

GIS二次开发实验报告

目录一、实验一:软件安装与AOI书签开发 (1)1.1实验目的 (1)1.2实验内容 (1)1.3实验步骤与结果 (1)二、实验二:地图数据组织与访问 (9)2.1实验目的 (9)2.2实验内容 (9)2.3实验步骤与结果 (9)三、实验三:地图渲染与制图输出 (15)3.1实验目的 (15)3.2实验内容 (15)3.3实验步骤结果 (15)3.3.1实现图层基本渲染 (15)3.3.2打印页面布局 (21)3.3.3制图文件输出 (25)四、实验四:空间数据处理 (28)4.1实验目的 (28)4.2实验内容 (28)4.3实验步骤与结果 (28)4.3.1创建一个Shapefile文件 (28)4.3.2创建新要素 (32)五、实验五:GIS分析 (37)5.1实验目的 (37)5.2实验内容 (37)5.3实验步骤与结果 (37)5.3.1空间关系示例 (37)5.3.2缓冲区分析 (40)5.3.3要素统计实例 (43)六、实验六:栅格数据处理 (46)6.1实验目的 (46)6.2实验内容 (46)6.3实验步骤与结果 (46)6.3.1创建栅格数据集 (46)6.3.2栅格数据格式转换 (49)6.3.3栅格影像镶嵌 (51)6.3.4栅格统计 (55)七、实验总结 (58)一、实验一:软件安装与AOI书签开发1.1实验目的✧掌握ArcGIS Engine开发环境的相关软件安装✧掌握AOI书签程序开发1.2实验内容✧安装Visual Studio 2010✧安装Microsoft .NET Framework 3.5✧安装ArcGIS Engine 10.2✧安装ArcObjects Developer kit For Microsoft .NET Framework 10.2✧安装ArcGIS License Manager,并授权✧实现AOI书签的创建✧实现AOI书签的调用1.3实验步骤与结果1.3.1安装Visual Studio 20101.3.2安装Microsoft .NET Framework 3.51.3.3安装ArcGIS Engine 10.21.3.4安装ArcObjects Developer kit For Microsoft .NET Framework 10.21.3.5安装ArcGIS License Manager,并授权1.3.6实现AOI书签的创建1.3.6.1添加控件和类库引用1.3.6.2添加“创建书签”函数在MainForm类定义内容添加一个成员函数,以创建书签。

《GIS二次开发》课程设计报告

《GIS二次开发》课程设计报告

《GIS二次开发课程设计》报告目录1 设计目标 (1)2 需求分析 (1)2.1 业务构成 (1)2.2 数据内容 (1)3 系统设计 (1)3.1 总体设计 (1)3.2 数据库设计 (2)3.3 平台选择 (2)3.4 详细设计 (2)4 功能实现 (3)4.1 基本功能 (3)4.2 符号化 (3)小结 ............................ 错误!未定义书签。

1 设计目标通过本系统的实施,建立全国各省人口分布和人均GDP排名系统,通过各种地图符号和色彩信息,将地图数据符号化,借此来制作全国各省人口比重、贫富差距大小等专题图。

2 需求分析2.1 业务构成中国人口在世界各国中位居首位,约占世界总人口的19%,根据2015年1月20日国家统计局网站公布2014年中国经济数据,2014年末,中国大陆总人口达136782万人,比上年末增加710万人。

其中,男性人口70079万人,女性人口66703万人,男性人口比女性多3376万人。

中国是人口大国,因此中国的人口分布情况和人口管理显得至关重要。

随着经济的发展,中国的经济状况日益增强。

但是整体而言贫富差距还是很大,所以将地图数据符号化来更好地分析各地区的人均GDP对国家掌控各地经济情况是十分有用的。

2.2 数据内容数据主要包括全国各省的人口数量、总的GDP和人均GDP。

通过这些数据来处理地图,将地图做成不同属性的专题图。

3 系统设计3.1 总体设计此次设计的初衷即是开发一个可以制作专题地图的系统。

以全国人口数量和全国各省人均GDP为例进行制作和开发。

第一步就是找全国省区底图;接着找所需数据(全国各省人口数量和全国各省人均GDP。

)最后,通过VS设计系统,实现专题图制作功能。

3.2 数据库设计刚开始是想将找到的数据以表格的形式导入arccatalog中,希望经过处理可以直接使用,但是做到最后发现并不能将表格直接导入底图。

解决办法是在arcmap中编辑底图的属性表将找到的数据输入,保存。

GIS二次开发综合实验报告

GIS二次开发综合实验报告

二次开发综合实验报告目录实验一:设计界面,添加鹰眼控件 ____________________________________________ 1 1.1实验目的__________________________________________________________________ 1 1.2实验内容__________________________________________________________________ 1 1.3实验步骤与结果____________________________________________________________ 1实验二:利用菜单,打开MXD文档,Shapefile文件_____________________________ 4 2.1实验目的__________________________________________________________________ 4 2.2实验内容__________________________________________________________________ 4 2.3实验步骤与结果____________________________________________________________ 4实验三:实现鹰眼功能______________________________________________________ 7 3.1实验目的__________________________________________________________________ 7 3.2实验内容__________________________________________________________________ 7 3.3实验步骤结果______________________________________________________________ 7实验四:实现右键查询图层信息以及删除图层操作 _____________________________ 11 4.1实验目的_________________________________________________________________ 11 4.2实验内容_________________________________________________________________ 11 4.3实验步骤与结果___________________________________________________________ 11实验五:使用多边形选择区域内部要素,并高亮显示____________________________ 21 5.1实验目的_________________________________________________________________ 21 5.2实验内容_________________________________________________________________ 21 5.3实验步骤与结果___________________________________________________________ 21实验六:实现柱状图渲染__________________________________________________ 23 6.1实验目的_________________________________________________________________ 23 6.2实验内容_________________________________________________________________ 23 6.3实验步骤与结果___________________________________________________________ 23实验七:实现最短路径分析(网络分析) ____________________________________ 27 7.1实验目的_________________________________________________________________ 27 7.2实验内容_________________________________________________________________ 27 7.3实验步骤与结果___________________________________________________________ 27实验总结__________________________________________________ 错误!未定义书签。

GIS二次开发试验报告

GIS二次开发试验报告

GIS二次开发程序设计实习报告实验课程:GIS二次开发程序设计实验名称:设计程序完成图像基本操作班级:地信101学号: 1022062011姓名:汪翔实验日期: 2013 年 4 月 5 日GIS二次开发程序设计实习报告 (1)一.选题名称 (3)二.研究现状 (3)三.研究思路与方法 (3)四.编程与实现 (4)Arcmap下实现 (4)vb代码 (4)实现结果 (12)VS下实现 (13)C#代码 (14)五.结果与分析 (21)一.选题名称本次GIS二次程序设计实习中我所研究的是空间信息量算分析中的延伸率分析。

二.研究现状GIS的发展引领着空间分析也在迅速的走向成熟,因为空间分析作为GIS的核心技术,同时也是区别于其它信息系统的主要特征,能够根据地理对象的位置和形态特征等采用相关分析模型对其进行综合性的分析、预测乃至决策和支持。

本文针对空间分析在城市发展建设中的作用以及具体内容进行了探讨研究。

我所研究的延伸率是反应城市空间离散程度的一个重要指标,它的计算公式为:延伸率=L/L’L为区域最长轴的长度,L’为区域最短轴的长度三.研究思路与方法当把城市当作单个面状目标看待时,可以直接使用面状目标的形状系数,如延伸率,形状比,紧凑度,圆形率等。

这些指标计算较简单,反应一个抽象的形状。

当把城市看成是面状目标的几何,可以使用放射状指数,标准面积指数等较为复杂的指标来计算。

反应了城市内部的具体联系。

根据这些指标,可以为政府决策,商业运行,旅游开发等一系列经济文化活动带来较为科学的评价指标和行为指导。

在本次实习中,我所研究的方向是利用延伸率来研究城市的空间。

延伸率反应城市空间的带状延伸程度,带状延伸越明显则城市延伸率越大,反应城市的离散程度越大。

四.编程与实现本次实习中主要利用的平台有ArcMap 以及Visual Studio,用于实现的语言有C#及VB,我在老师的指导和查阅书籍的情况下,分别用两种语言实现延伸率的量算,现将结果展示如下:1)在ArcMap下利用VB进行实现:1.创建一个UI按钮控件,重命名为延伸率,打开代码编辑窗口。

gis二次开发实训总结

gis二次开发实训总结

gis二次开发实训总结GIS(地理信息系统)二次开发实训总结一、引言GIS(地理信息系统)是一种将地理空间信息与属性信息相结合的技术系统,广泛应用于地理信息管理、地理空间分析、空间决策支持等领域。

在GIS软件应用过程中,二次开发能够满足特定需求,提高工作效率和数据处理能力。

本文将总结我在GIS二次开发实训中的学习经验和体会。

二、实训内容实训内容主要包括GIS软件的基本操作、二次开发的常用工具和技术、以及实际项目的开发。

在实训中,我通过学习和实践,掌握了GIS软件的基本操作技巧,如数据导入、地图绘制、属性查询等。

同时,我还学习了GIS二次开发的常用工具和技术,如ArcGIS Engine、ArcObjects、ArcPy等,这些工具和技术能够帮助我们进行地理空间数据的处理和分析。

在实训的最后阶段,我还参与了一个实际项目的开发,通过对项目需求的分析和编码实现,完成了一个基于GIS的地理空间分析系统。

三、学习经验1. 系统学习GIS基础知识:在进行GIS二次开发之前,充分了解GIS的基本概念和原理非常重要。

只有对GIS的基础知识有清晰的认识,才能更好地进行二次开发工作。

2. 熟悉GIS软件的操作:熟练掌握GIS软件的操作是进行二次开发的基础。

通过反复练习和实践,我逐渐熟悉了GIS软件的各种功能和操作方法,提高了工作效率。

3. 深入学习GIS二次开发工具和技术:GIS二次开发涉及到一些专门的工具和技术,如ArcGIS Engine、ArcObjects、ArcPy等。

通过深入学习这些工具和技术,我能够更好地进行地理空间数据处理和分析,并实现特定需求。

4. 学会利用网络资源:在进行GIS二次开发过程中,遇到问题时,学会利用网络资源进行查找和解决是非常重要的。

通过查阅相关文档和论坛,我解决了许多开发中的问题。

5. 多实践、多项目参与:只有不断地实践和参与项目,才能真正掌握GIS二次开发的技巧和经验。

在实践中,我遇到了许多问题,但通过不断尝试和摸索,最终都找到了解决方法。

(完整word版)二次开发实习报告

(完整word版)二次开发实习报告

GIS二次开发实验实验报告学院:测绘工程学院专业:地理信息系统班级:1123101姓名:岳志鹏学号:201120310114课程名称:Supermap objects 组件式开发指导老师:徐效波2014年01月目录GIS二次开发实验 ............................................................................ - 1 -一、实验背景........................................................................................ - 3 -二、实验目的........................................................................................ - 3 -三、实验内容及过程 ........................................................................... - 3 -实验一:快速入门 ......................................................................... - 3 -1. 新建项目 ........................................................................ - 3 -2. 数据准备 ........................................................................ - 4 -3. 添加控件 ........................................................................ - 4 -4. 添加菜单项 .......................................................................... - 5 -5.控件的关联 ......................................................................... - 5 -6. 打开工作空间 ...................................................................... - 6 -8. 地图浏览操作 .................................................................... - 7 -9. 显示属性信息 ...................................................................... - 8 -10. 地图量算 ...................................................................... - 9 -实验二:查询功能 ....................................................................... - 10 -1、案例分析 ........................................................................... - 10 -2、准备的数据 ....................................................................... - 10 -3、主要使用的接口和操作 ................................................... - 11 -(1)查找Missouri河: ................................................. - 11 -(2)查询Missouri河穿过的州:................................. - 12 -(3)查询Missouri河200公里以内的县:................. - 14 -(4)查询South Dakota州包含的州: ....................... - 15 -(5)关联查询South Dakota州的人口数: ............... - 17 - 四、实验总结...................................................................................... - 19 -一、实验背景近年来,随着社会信息化发展进程的不断推进,信息所具备的空间特性在众多社会活动公共行政决策和商业决策中发挥的作用越来越大。

GIS二次开发综合实验报告

GIS二次开发综合实验报告

二次开发综合实验报告目录实验一:设计界面,添加鹰眼控件 ____________________________________________ 1 1.1实验目的__________________________________________________________________ 1 1.2实验内容__________________________________________________________________ 1 1.3实验步骤与结果____________________________________________________________ 1实验二:利用菜单,打开MXD文档,Shapefile文件_____________________________ 4 2.1实验目的__________________________________________________________________ 4 2.2实验内容__________________________________________________________________ 4 2.3实验步骤与结果____________________________________________________________ 4实验三:实现鹰眼功能______________________________________________________ 7 3.1实验目的__________________________________________________________________ 7 3.2实验内容__________________________________________________________________ 7 3.3实验步骤结果______________________________________________________________ 7实验四:实现右键查询图层信息以及删除图层操作 _____________________________ 11 4.1实验目的_________________________________________________________________ 11 4.2实验内容_________________________________________________________________ 11 4.3实验步骤与结果___________________________________________________________ 11实验五:使用多边形选择区域内部要素,并高亮显示____________________________ 21 5.1实验目的_________________________________________________________________ 21 5.2实验内容_________________________________________________________________ 21 5.3实验步骤与结果___________________________________________________________ 21实验六:实现柱状图渲染__________________________________________________ 23 6.1实验目的_________________________________________________________________ 23 6.2实验内容_________________________________________________________________ 23 6.3实验步骤与结果___________________________________________________________ 23实验七:实现最短路径分析(网络分析) ____________________________________ 27 7.1实验目的_________________________________________________________________ 27 7.2实验内容_________________________________________________________________ 27 7.3实验步骤与结果___________________________________________________________ 27实验总结__________________________________________________ 错误!未定义书签。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

GIS二次开发实验报告学号:姓名:班级:专业:目录1系统特色 (1)2DotNetBar介绍 (3)3文件打开实现 (4)4多标签切换实现 (7)5 属性表实现 (8)6柱状图渲染实现 (10)7 状态条实现与比例尺调整实现 (15)8 最短路径分析实 (16)9 多边形选择 (23)10 鹰眼设计实现 (24)11 实验总结 (25)1系统特色系统特色:1、人性化界面,大标签UI。

2、D otNetBar控件同ArcGis控件结合,提升系统的整体美观程度。

3、一体化仿Office主题设计,色调和谐。

4、多标签模式,支持同时打开多个文档。

5、属性设置方便直观。

6、图层窗、鹰眼窗、属性表窗支持任意拖动调整位置与停靠。

2DotNetBar介绍DotNetBar是一组用于.NET Framework环境下的一组组件集,利用该组件集能够打造绚丽并且实用的应用程序界面,给开发人员提供极大的便利。

由于DotNetBar2内容极为丰富,因此先在工具箱中“添加选项卡”(DotNetBar2),然后在此选项卡下“选择项”,浏览DevComponents.DotNetBar2.dll文件,显示如下:3 文件打开实现● 单击“文件”按钮,会弹出“打开”和“关闭”选项,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 private void OpenMXD_Click(object sender, EventArgs e)//“打开MXD 文件”按钮{OpenFileDialog ofDialog = new OpenFileDialog();ofDialog.Title = "输入ArcMap 文档名称";ofDialog.Filter = "ArcView MXD 文件|*.mxd";ofDialog.Multiselect = false ;if (ofDialog.ShowDialog() == DialogResult.OK)openFile(ofDialog.FileName, false );}private void Openshape_Click(object sender, EventArgs e)//“打开shape 文件”按钮{IWorkspaceFactory shpFactory = new ShapefileWorkspaceFactoryClass();OpenFileDialog ofDialog = new OpenFileDialog();ofDialog.Title = "输入ArcMap 文档名称";ofDialog.Filter = "ArcView Shape 文件|*.shp";ofDialog.Multiselect = false ;if (ofDialog.ShowDialog() == DialogResult.OK){string fileName = ofDialog.FileName;string filePath = fileName.Substring(0, stIndexOf('\\'));IWorkspace shpWorkspace = shpFactory.OpenFromFile(filePath, 0);IFeatureLayer ftlayer = new FeatureLayerClass();IEnumDataset ds = shpWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass); IDataset featureClass = ds.Next();ftlayer.FeatureClass = (IFeatureClass)featureClass; = fileName;ILayer layer = ftlayer as ILayer;IMap mmap = sizelist[(int )superTabControl.SelectedTab.Tag].Map;mmap.AddLayer(layer);IActiveView act = mmap as IActiveView;act.Refresh();}}● 执行“打开文档”命令,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public void openFile(string fileName, bool isRecentFile)//打开文档{ribbonTabItem2.Enabled = false ;ribbonTabItem1.Enabled = true ;m_ipPathFinder = null ;if (!isRecentFile)//如果不是从“最近打开”处打开的则记录该文档名writeRecentFile(fileName);if (switch1)//当不是空文档时{ switch2 = false ;//新建一个文档标签为去地址文件名的标签SuperTabItem tabItem =superTabControl.CreateTab(System.IO.Path.GetFileNameWithoutExtension(fileName)); AxMapControl newaxmap = new AxMapControl();sizelist.Add(newaxmap);newaxmap.SendToBack();newaxmap.Dock = DockStyle.Fill;18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 tabItem.AttachedControl.Controls.Add(newaxmap);superTabControl.SelectNextTab();superTabControl.SelectedTab.Tag = n++;newaxmap.LoadMxFile(fileName);axTOCClayer.SetBuddyControl(newaxmap);superTabControl.SelectNextTab();newaxmap.OnMouseMove +=new IMapControlEvents2_Ax_OnMouseMoveEventHandler(axMapControlOnMouseMove);switch2 = true ;newaxmap.OnMouseDown +=new IMapControlEvents2_Ax_OnMouseDownEventHandler(axMapControlOnMouseDown);}else //否则直接载入{superTabControl.SelectedTab.Text =System.IO.Path.GetFileNameWithoutExtension(fileName);sizelist[(int )superTabControl.SelectedTab.Tag].LoadMxFile(fileName);switch1 = true ;}anotherrefresh();//刷新标签switch2 = true ;bar4.Show();//鹰眼框,图层框可用bar5.Show();bar5.AutoHide = true ;axMapEagleEye.Extent = axMapEagleEye.FullExtent;axMapEagleEye.ActiveView.Refresh();//读取刚载入的地图的图层和字段信息getLayerInfo(sizelist[(int )superTabControl.SelectedTab.Tag]);getAttributeInfo(sizelist[(int )superTabControl.SelectedTab.Tag]);}本系统支持快速打开最近曾经打开过的文档,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 public void writeRecentFile(string filename)//写入“最近文档”的记录文件{try{StreamWriter s = new StreamWriter("\\Menu.ini", true );s.WriteLine(filename);s.Flush();s.Close();}catch { }}public void readRecentFile()//读取最近打开的文档{itemContainer4.SubItems.Clear();try {StreamReader sr = new StreamReader("\\Menu.ini");while (sr.Peek() >= 0){ButtonItem recentFile = new ButtonItem();recentFile.Tag = sr.ReadLine();recentFile.Text = "&" + System.IO.Path.GetFileNameWithoutExtension((string )recentFile.Tag); recentFile.Click += new EventHandler(openRecentFile);itemContainer4.SubItems.Add(recentFile);}}catch { }}public void openRecentFile(object sender, EventArgs e)//打开最近打开的文档30 31 32 33 {ButtonItem tempButton = (ButtonItem)sender;openFile((string )tempButton.Tag, true );}● 清除“最近打开栏”中的记录,代码如下:1 2 3 4 5 6 7 8 private void clearRecentFile_Click(object sender, EventArgs e)//清除“最近打开”{itemContainer4.SubItems.Clear();System.IO.FileStream stream = File.Open("\\Menu.ini", FileMode.OpenOrCreate, FileAccess.Write); stream.Seek(0, SeekOrigin.Begin);stream.SetLength(0);stream.Close();}● 当当前标签没有加载地图时,初始化一个空文档,代码如下:12 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 private void FormWithNoDocument()//初始化一个空文档{ribbonTabItem1.Enabled = false ;//空文档下不能进行图层选择操作ribbonTabItem2.Enabled = false ;bar5.Hide();//鹰眼框,图层框,属性表框都隐藏superTabControl.CreateTab("空文档");//创建标签为“空文档”的标签superTabControl.SelectedTab.Tag = n++;bar4.Hide();bar3.Hide();AxMapControl newaxmap = new AxMapControl();//动态创建一个axmapcontrolnewaxmap.BeginInit();newaxmap.SendToBack();newaxmap.Dock = DockStyle.Fill;sizelist.Add(newaxmap);superTabControl.SelectedTab.AttachedControl.Controls.Add(newaxmap);//将其加入该标签newaxmap.OnExtentUpdated +=new IMapControlEvents2_Ax_OnExtentUpdatedEventHandler(axMapControlOnExtentUpdated);newaxmap.OnMouseMove +=new IMapControlEvents2_Ax_OnMouseMoveEventHandler(axMapControlOnMouseMove);newaxmap.OnMouseDown +=new IMapControlEvents2_Ax_OnMouseDownEventHandler(axMapControlOnMouseDown);newaxmap.EndInit();axTOCClayer.SetBuddyControl(newaxmap);//设置为关联组件BTNattribute1.SubItems.Clear();//初始化所有图层、字段选择框BTNlayer1.SubItems.Clear();buttonItem4.SubItems.Clear();buttonItem7.SubItems.Clear();}单击文件按钮,弹出菜单4 多标签切换实现● 相应“关闭标签”事件,代码如下:1 2 3 4 5 6 7 8 9 private void superTabControl1_TabItemClose(object sender, SuperTabStripTabItemCloseEventArgs e) {if (superTabControl.Tabs.Count == 1)//如果只剩下唯一一个t 标签(一定是“空文档”标签){switch2 = false ; switch1 = false ;FormWithNoDocument();}}● 相应“标签切换”事件,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34//当不是空文档时切换的文档标签切换事件private void superTabControl_SelectedTabChanged(object sender, SuperTabStripSelectedTabChangedEventArgs e){if (switch2){m_ipPathFinder = null ;axMapEagleEye.LoadMxFile(sizelist[(int )superTabControl.SelectedTab.Tag].DocumentFilename);//加载该文档 axMapEagleEye.Extent = axMapEagleEye.FullExtent;axMapEagleEye.ActiveView.Refresh();axTOCClayer.SetBuddyControl(sizelist[(int )superTabControl.SelectedTab.Tag]);//重新设置关联组件axTOCClayer.ActiveView.Refresh();nowSelectedLayer = 0;//初始化选择的图层getLayerInfo(sizelist[(int )superTabControl.SelectedTab.Tag]);//重新读取该文档的信息 getAttributeInfo(sizelist[(int )superTabControl.SelectedTab.Tag]);} }private void anotherrefresh()//当是空文档时切换的文档标签切换事件{m_ipPathFinder = null ;axMapEagleEye.LoadMxFile(sizelist[(int )superTabControl.SelectedTab.Tag].DocumentFilename);axMapEagleEye.Extent = axMapEagleEye.FullExtent;axMapEagleEye.ActiveView.Refresh();axTOCClayer.SetBuddyControl(sizelist[(int )superTabControl.SelectedTab.Tag]);axTOCClayer.ActiveView.Refresh();nowSelectedLayer = 0;getLayerInfo(sizelist[(int )superTabControl.SelectedTab.Tag]);getAttributeInfo(sizelist[(int )superTabControl.SelectedTab.Tag]);}5 属性表实现● 相应右键菜单“查看属性表” ,代码如下:1 2 3 4 5 6 7 8 9 private void 查看属性表ToolStripMenuItem_Click(object sender, EventArgs e){if (!barisshow){shuxingbiao(); barisshow = true ;//表示属性表已打开查看属性表ToolStripMenuItem.Enabled = false ;}}● 相应ArcGis 图层列表单击事件,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21ILayer m_Layer;//记录图层,提供给数据窗private void axTOCControlOnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)//右键菜单 {AxTOCControl axt1 = (AxTOCControl)sender;esriTOCControlItem Item = esriTOCControlItem.esriTOCControlItemNone;IBasicMap pBasicMap = null ;ILayer pLayer = null ;object other = null ;object index = null ;//根据点击位置实现赋值axt1.HitTest(e.x, e.y, ref Item, ref pBasicMap, ref pLayer, ref other, ref index); m_Layer = pLayer; if (Item == esriTOCControlItem.esriTOCControlItemLayer|| Item == esriTOCControlItem.esriTOCControlItemLegendClass)//如果点击的地方是图层名或者图例 {if (e.button == 2)//显示右键菜单,并定义其相对控件的位置,正好在鼠标出显示contextMenuStrip1.Show(axt1, new System.Drawing.Point(e.x, e.y));else if (barisshow)//若已打开属性表框则左键点击直接显示其属性shuxingbiao();}}● 显示属性表,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 private void shuxingbiao()//显示所选图层的属性表{IFeatureLayer pFeatureLayer = m_Layer as IFeatureLayer;IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;IFeatureCursor pFeatureCursor = pFeatureClass.Search(null , false );IFeature pFeature = pFeatureCursor.NextFeature();IFields pFields = pFeatureClass.Fields;int n1 = 0, n2 = 0;DataTable pTable = new DataTable();for (int i = 0; i < pFields.FieldCount; i++)//获取所有列{DataColumn pColumn = new DataColumn(pFields.get_Field(i).Name);if (pFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)n1 = i;15161718192021222324252627282930313233pTable.Columns.Add(pColumn);}while (pFeature != null){DataRow pRow = pTable.NewRow();for (int i = 0; i < pFields.FieldCount; i++)//添加每一列的值 {pRow[i] = pFeature.get_Value(i);}pRow[n1] = getshapetype(m_Layer);pTable.Rows.Add(pRow);pFeature = pFeatureCursor.NextFeature();n2++;}dockContainerItem1.Control.Show();dataGridViewX1.DataSource = pTable;bar3.Show();barisshow = true;}右键显示属性表,属性表在下方显示6 柱状图渲染实现● 初始化图层信息,并将其添加到“选择图层”按钮的子项中,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33int pointLayer = 0;//记录点图层编号 private void getLayerInfo(AxMapControl axmaptemp)//读取图层信息 { BTNlayer1.SubItems.Clear();//清理菜单项的遗留 buttonItem4.SubItems.Clear(); BTNlayer2.SubItems.Clear(); for (int i = 0; i < yerCount; i++) { ButtonItem newButtonItem = new ButtonItem();//新建菜单项 newButtonItem.Text = axmaptemp.get_Layer(i).Name;//将图层名赋予新建菜单项 newButtonItem.Tag = i;//设置该菜单项与图层对应的编号 newButtonItem.AutoCollapseOnClick = true ; newButtonItem.Click += new EventHandler(readLayerInfo);//绑定事件 BTNlayer1.SubItems.Add(newButtonItem);//加为该按钮的子项菜单 ButtonItem newButtonItem2 = new ButtonItem(); newButtonItem2.Text = axmaptemp.get_Layer(i).Name; newButtonItem2.Tag = i; newButtonItem2.AutoCollapseOnClick = true ; newButtonItem2.Click += new EventHandler(readLayerInfo); buttonItem4.SubItems.Add(newButtonItem2); //若图层为点图层,则显示为BTNlayer2按钮的子项,因为要求路径点为点图层 if (getshapetype(axmaptemp.get_Layer(i)) == "点") { pointLayer = i; ButtonItem newButtonItem3 = new ButtonItem(); newButtonItem3.Text = axmaptemp.get_Layer(i).Name; newButtonItem3.Tag = i; newButtonItem3.AutoCollapseOnClick = true ; newButtonItem3.Click += new EventHandler(readLayerInfo); BTNlayer2.SubItems.Add(newButtonItem3); } } }● 确定要显示哪些图层的函数,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //确定字段的值是不是数字,因为有些功能限制某些字段必为值 public static int ParseFieldType(esriFieldType fieldType) { switch (fieldType) { case esriFieldType.esriFieldTypeInteger: return 2; case esriFieldType.esriFieldTypeDouble: return 1; case esriFieldType.esriFieldTypeSmallInteger: return 2; default : return 0; } }● 读取所选择的图层,代码如下:1 2 3 4 5 6 private void readLayerInfo(object sender, EventArgs e)//读取所选择的图层 {ButtonItem tempButton = (ButtonItem)sender; nowSelectedLayer = (int )tempButton.Tag;getAttributeInfo(sizelist[(int )superTabControl.SelectedTab.Tag]); }● 根据所选择的图层,初始化字段信息,并将其添加到“选择字段”按钮的子项中,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 //颜色选择器记录列表,记录所有被添加的颜色选择器 List<ColorPickerDropDown> allColor = new List<ColorPickerDropDown>(); int checkboxnum = 0;//记录复选框的编号,为了与颜色选择器对应 List<CheckBoxItem> allcheckbox = new List<CheckBoxItem>(); private void getAttributeInfo(AxMapControl axmaptemp)//获取字段信息 { allColor.Clear();//清空颜色选择器记录列表 allcheckbox.Clear();//清空复选框记录列表 checkboxnum = 0; BTNattribute1.SubItems.Clear();//清空属性列表 buttonItem7.SubItems.Clear(); //获取属性字段 IFeatureLayer pFeatureLayer = axmaptemp.get_Layer(nowSelectedLayer) as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IFeatureCursor pFeatureCursor = pFeatureClass.Search(null , false ); IFeature pFeature = pFeatureCursor.NextFeature(); IFields pFields = pFeatureClass.Fields; for (int k = 0; k < pFields.FieldCount; k++) //获取所有列 { if (ParseFieldType(pFields.get_Field(k).Type) != 0)//只选择值为数字的字段 { CheckBoxItem newcheckbox = new CheckBoxItem();//新建复选框 newcheckbox.Text = pFields.get_Field(k).Name;//赋名字 newcheckbox.AutoCollapseOnClick = false ; ButtonItem newbuttonIn = new ButtonItem(); newbuttonIn.Text = newcheckbox.Text; newcheckbox.Tag = checkboxnum; allcheckbox.Add(newcheckbox); ColorPickerDropDown newColorPicker = new ColorPickerDropDown(); allColor.Add(newColorPicker); newbuttonIn.Tag = checkboxnum; newbuttonIn.Click += new EventHandler(selectedAttribute); newColorPicker.Tag = checkboxnum++; newColorPicker.Symbol = buttonX1.Symbol;//设置颜色选择器的图标 newColorPicker.ShowSubItems = false ; newColorPicker.AutoCollapseOnClick = false ; newColorPicker.AutoExpandOnClick = true ; newColorPicker.SelectedColorChanged += new EventHandler(colorPickerDropDownSelectedColorChanged); newColorPicker.AutoDisposeImages = true ; newColorPicker.SymbolSize = 12; newColorPicker.PopupSide = ePopupSide.Left;//设置颜色选择器向左弹出子菜单 DevComponents.DotNetBar.ItemContainer newItemContainer = new ItemContainer(); newItemContainer.SubItems.Add(newColorPicker); newItemContainer.SubItems.Add(newcheckbox); BTNattribute1.SubItems.Add(newItemContainer); buttonItem7.SubItems.Add(newbuttonIn); }49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 if (m_ipPathFinder == null )//打开几何网络工作空间,为网络分析做准备 { m_ipPathFinder = new ClsPathFinder(); IMap ipMap = axmaptemp.Map; ILayer ipLayer = ipMap.get_Layer(pointLayer); IFeatureLayer ipFeatureLayer = ipLayer as IFeatureLayer; IFeatureDataset ipFDB = ipFeatureLayer.FeatureClass.FeatureDataset; m_ipPathFinder.SetOrGetMap = ipMap; if (m_ipPathFinder.OpenFeatureDatasetNetwork(ipFDB)) ribbonTabItem2.Enabled = true ; else //弹出错误提示 { balloonTip1.SetBalloonText(ribbonControl1, "打开network 出错,不支持网络分析!"); balloonTip1.ShowBalloon(ribbonControl1); } } } }● 读取所选择的字段及对应字段的颜色,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 List<string > strCollected = new List<string >();//要进行柱状图渲染的字段 int nowSelectedLayer = 0; private void readAttributeInfo(object sender, EventArgs e)//根据所选择的图层读取该涂层的字段信息 { colorCollection.Clear();//初始化被选择颜色集合 strCollected.Clear();//初始化字段选择集合 for (int i = 0; i < allcheckbox.Count; i++) { if (allcheckbox[i].Checked)//若该字段被选中 { strCollected.Add(allcheckbox[i].Text);//将字段加入字段集合 IRgbColor tempColor = new RgbColor();//临时颜色变量 if (allColor[i].SelectedColor != Color.Empty)//如果设置了颜色,则设为该色 { tempColor.Red = allColor[i].SelectedColor.R; tempColor.Green = allColor[i].SelectedColor.G; tempColor.Blue = allColor[i].SelectedColor.B; } else //否则设为随机深颜色 tempColor = GetRandomDarkColor(); colorCollection.Add(tempColor);//被选择颜色集合加入此色 } } }● 进行柱状图渲染,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 List<IRgbColor> colorCollection = new List<IRgbColor>();//颜色集合 public void BarChartRenderer(ILayer pLayer, List<string > FieldNames)//构造柱状图 { IChartRenderer pChartRenderer = new ChartRendererClass(); IRendererFields pRendererFields = pChartRenderer as IRendererFields; for (int i = 0; i < FieldNames.Count; i++) { pRendererFields.AddField(FieldNames[i], FieldNames[i]);//读取所有被选中的字段 } IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;1314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 int FieldsNum = FieldNames.Count;int[] FieldIndecies = new int[FieldsNum]; for (int i = 0; i < FieldsNum; i++){FieldIndecies[i] = pFeatureClass.FindField(FieldNames[i]);//将字段对应起来if (FieldIndecies[i] == -1){MessageBox.Show("选择的字段名称有错误!");return;}}bool FirstValue = true;double MaxValue = -1;//初始化一个最大值for (int i = 0; i < FieldsNum; i++){IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);IFeature pFeature = pFeatureCursor.NextFeature();while (pFeature != null){double FieldValue = Convert.ToDouble(pFeature.get_Value(FieldIndecies[i]));if (FirstValue)//筛选最大值{MaxValue = FieldValue;FirstValue = false;}else if (FieldValue > MaxValue)MaxValue = FieldValue;pFeature = pFeatureCursor.NextFeature();}}IBarChartSymbol pBarChartSymbol = new BarChartSymbolClass();// 定义并设置渲染类型 pBarChartSymbol.Width = barwidth;//设置条带宽度IChartSymbol pChartSymbol = pBarChartSymbol as IChartSymbol;IMarkerSymbol pMarkerSymbol = pBarChartSymbol as IMarkerSymbol;pChartSymbol.MaxValue = MaxValue;// 设置pChartSymbol的最大值pMarkerSymbol.Size = maxHeighth;// 设置bar的最大高度ISymbolArray pSymbolArray = pBarChartSymbol as ISymbolArray;//给一个bar设置符号 ISimpleFillSymbol pSimpleFillSymbol;IRgbColor pColor;for (int i = 0; i < FieldsNum; i++)//读取各个字段的颜色{pColor = colorCollection[i];pSimpleFillSymbol = new SimpleFillSymbolClass();pSimpleFillSymbol.Color = pColor;pSymbolArray.AddSymbol(pSimpleFillSymbol as ISymbol);}pColor = GetRandomLightColor();//设置背景符号pSimpleFillSymbol = new SimpleFillSymbolClass();pSimpleFillSymbol.Color = pColor;pChartRenderer.BaseSymbol = pSimpleFillSymbol as ISymbol;eOverposter = false;pChartRenderer.ChartSymbol = pChartSymbol;pChartRenderer.CreateLegend();pGeoFeatureLayer.Renderer = pChartRenderer as IFeatureRenderer;sizelist[(int)superTabControl.SelectedTab.Tag].ActiveView.Refresh();}若未定义颜色,则自动生成颜色,代码如下:4 5 6 7 8 91011121314151617181920212223242526272829303132 int nRed, nGreen, nBlue; int redLow = 180;int greenLow = 180;int blueLow = 180;nRed = random.Next(redLow);nGreen = random.Next(greenLow);nBlue = random.Next(blueLow);IRgbColor color = new RgbColor();color.Red = nRed;color.Green = nGreen;color.Blue = nBlue;return color;}public IRgbColor GetRandomLightColor()//生成随机浅色{int nRed, nGreen, nBlue;int high = 255;int Low = 200;nRed = random.Next(Low, high);nGreen = random.Next(Low, high);nBlue = random.Next(Low, high);IRgbColor color = new RgbColor();color.Red = nRed;color.Green = nGreen;color.Blue = nBlue;return color;}柱状图渲染菜单如图所示选择字段并设置颜色生成的柱状图如图所示7 状态条实现与比例尺调整实现● 绑定主地图窗口的鼠标移动代码,代码如下:1 2 3 4 5private void axMapControlOnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { if (switch1)//若不是空文档则显示坐标 labelItem3.Text = "X=" + e.mapX.ToString() + " Y=" + e.mapY.ToString(); }● 绑定滑动条值改变代码,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16int nowvalue = 0;//当前缩放比例 private void SliderRating_ValueChanged(object sender, EventArgs e)//根据滑动条控制缩放比例 { intchange = SliderRating.Value - nowvalue; nowvalue = SliderRating.Value; IActiveView nowactive = sizelist[(int )superTabControl.SelectedTab.Tag].ActiveView; IEnvelope envolop = nowactive.Extent; if (change > 0) for (int n = 0; n < change; n++) envolop.Expand(0.9, 0.9, true ); else for (int n = 0; n < -change; n++) envolop.Expand(1.1, 1.1, true ); sizelist[(int )superTabControl.SelectedTab.Tag].Extent = envolop; nowactive.Refresh(); }● 绑定“恢复最小比例尺”按钮代码,代码如下:1 2 3 4 5private void BTNfullExtent_Click(object sender, EventArgs e)//全屏显示按钮 { sizelist[(int )superTabControl.SelectedTab.Tag].Extent = sizelist[(int )superTabControl.SelectedTab.Tag].FullExtent; }显示鼠标所指的图上坐标,坐标如图所示8 最短路径分析实绑定主地图窗口的鼠标按下代码,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52private void axMapControlOnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { AxMapControl axmaptem = (AxMapControl)sender; else if (BTNstartDraw.Checked == true )//如果“绘制”按钮被按下 { IGeometry g = null ; IEnvelope pEnv; IActiveView pActiveView = axmaptem.ActiveView; IMap pMap = axmaptem.Map; pEnv = axmaptem.TrackRectangle(); if (pEnv.IsEmpty == true )//建立一个10*10的矩形选区 { ESRI.ArcGIS.esriSystem.tagRECT r; r.bottom = e.y + 5; r.top = e.y - 5; r.left = e.x - 5; r.right = e.x + 5; pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4); pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference; } g = pEnv as IGeometry; ISelectionEnvironment pSelectionEnv = new SelectionEnvironment();//新建选择环境 IRgbColor pColor = new RgbColor(); pColor.Red = 255;//被选中的点为红色 pSelectionEnv.DefaultColor = pColor; //选择要素,true 表示在选择框里找到一个就停止搜索 axmaptem.Map.SelectByShape(g, pSelectionEnv, true ); axmaptem.Refresh(); IEnumFeatureSetup pEnumFeatureSetup = axmaptem.Map.FeatureSelection as IEnumFeatureSetup; pEnumFeatureSetup.AllFields = true ; IEnumFeature pEnumFeature = pEnumFeatureSetup as IEnumFeature; if (pEnumFeature == null ) return ; IFeature pFeature = pEnumFeature.Next(); //如果选择的要素是点要素 if (pFeature != null && pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { selectedFeature.Add(pFeature);//加入被选中点集合 axmaptem.Map.ClearSelection();//清除选区 foreach (IFeature featuretemp in selectedFeature)//重新绘制点要素集中所有的点 axmaptem.Map.SelectFeature(axmaptem.get_Layer(pointLayer), featuretemp); } else return ; if (m_ipPoints == null )//新建点集 m_ipPoints = new MultipointClass(); IPoint poi = (IPoint)pFeature.Shape; object o = Type.Missing; m_ipPoints.AddPoint(poi, o, o);//添加该点 m_ipPathFinder.StopPoints = m_ipPoints; } }● 选择权字段,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42string PofAttribute = "";//最短路径的权字段 private void selectedAttribute(object sender, EventArgs e)//选择最短路径的权字段 { ButtonItem tempbutton = (ButtonItem)sender; PofAttribute = tempbutton.Text; } int LineSymbolWidth = 5; private void BTNshortestWay_Click(object sender, EventArgs e)//构建最短路径 { if (PofAttribute == "") { balloonTip1.SetBalloonText(bar2, "请选择权字段"); balloonTip1.ShowBalloon(bar2); return ; } if (m_ipPathFinder.SetOrGetMap == null ) return ; m_ipPathFinder.SolvePath(PofAttribute);//先解析路径 IPolyline ipPolyResult = m_ipPathFinder.PathPolyLine();//最后返回最短路径 ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();//设置Symbol 属性 if (colorPickerDropDown1.SelectedColor == Color.Empty)//设置颜色 pLineSymbol.Color = GetRandomDarkColor(); else { IRgbColor tempcolor = new RgbColor(); tempcolor.Red = colorPickerDropDown1.SelectedColor.R; tempcolor.Green = colorPickerDropDown1.SelectedColor.G; tempcolor.Blue = colorPickerDropDown1.SelectedColor.B; pLineSymbol.Color = tempcolor; } pLineSymbol.Width = LineSymbolWidth; IElement m_Element = new LineElement(); m_Element.Geometry = ipPolyResult; ILineElement plinelement = (ILineElement)m_Element; plinelement.Symbol = pLineSymbol; IGraphicsContainer m_Container = sizelist[(int )superTabControl.SelectedTab.Tag].Map as IGraphicsContainer; m_Container.AddElement(m_Element, 0); m_ipPoints = null ; m_ipPathFinder.StopPoints = null ; sizelist[(int )superTabControl.SelectedTab.Tag].ActiveView.Refresh(); }● 实现“最短路径”类,代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 public class ClsPathFinder { private IGeometricNetwork m_ipGeometricNetwork; private IMap m_ipMap; private IPointCollection m_ipPoints; private IPointToEID m_ipPointToEID; private double m_dblPathCost = 0; private IEnumNetEID m_ipEnumNetEID_Junctions; private IEnumNetEID m_ipEnumNetEID_Edges; private IPolyline m_ipPolyline; public IMap SetOrGetMap //返回和设置当前地图 {14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 set { m_ipMap = value; } get { return m_ipMap; } } //打开几何数据集的网络工作空间 public bool OpenFeatureDatasetNetwork(IFeatureDataset FeatureDataset) { CloseWorkspace(); if (!InitializeNetworkAndMap(FeatureDataset)) return false ; return true ; } public IPointCollection StopPoints //输入点的集合 { set { m_ipPoints = value; } get { return m_ipPoints; } } public double PathCost //路径成本 { get { return m_dblPathCost; } } public IPolyline PathPolyLine()//返回路径的几何体 { IEIDInfo ipEIDInfo; IGeometry ipGeometry; if (m_ipPolyline != null ) return m_ipPolyline; m_ipPolyline = new PolylineClass(); IGeometryCollection ipNewGeometryColl = m_ipPolyline as IGeometryCollection; ISpatialReference ipSpatialReference = m_ipMap.SpatialReference; IEIDHelper ipEIDHelper = new EIDHelperClass(); ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork; ipEIDHelper.OutputSpatialReference = ipSpatialReference; ipEIDHelper.ReturnGeometries = true ; try { IEnumEIDInfo ipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_ipEnumNetEID_Edges); int count = ipEnumEIDInfo.Count; ipEnumEIDInfo.Reset(); for (int i = 0; i < count; i++) { ipEIDInfo = ipEnumEIDInfo.Next(); ipGeometry = ipEIDInfo.Geometry; ipNewGeometryColl.AddGeometryCollection(ipGeometry as IGeometryCollection); } } catch { }7778798081828384858687888990919293949596979899 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 return m_ipPolyline;}public void SolvePath(string WeightName)//解决路径{try{int intEdgeUserClassID;int intEdgeUserID;int intEdgeUserSubID;int intEdgeID;IPoint ipFoundEdgePoint;double dblEdgePercent;ITraceFlowSolverGEN ipTraceFlowSolver =new TraceFlowSolverClass() as ITraceFlowSolverGEN;INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver;INetwork ipNetwork = m_work;ipNetSolver.SourceNetwork = ipNetwork;INetElements ipNetElements = ipNetwork as INetElements;int intCount = m_ipPoints.PointCount;IEdgeFlag[] pEdgeFlagList = new EdgeFlagClass[intCount];//定义一个边线旗数组for (int i = 0; i < intCount; i++){INetFlag ipNetFlag = new EdgeFlagClass() as INetFlag;IPoint ipEdgePoint = m_ipPoints.get_Point(i);m_ipPointToEID.GetNearestEdge//查找输入点的最近的边线(ipEdgePoint, out intEdgeID, out ipFoundEdgePoint, out dblEdgePercent);ipNetElements.QueryIDs(intEdgeID, esriElementType.esriETEdge,out intEdgeUserClassID, out intEdgeUserID, out intEdgeUserSubID);erClassID = intEdgeUserClassID;erID = intEdgeUserID;erSubID = intEdgeUserSubID;IEdgeFlag pTemp = (IEdgeFlag)(ipNetFlag as IEdgeFlag);pEdgeFlagList[i] = pTemp;}ipTraceFlowSolver.PutEdgeOrigins(ref pEdgeFlagList);INetSchema ipNetSchema = ipNetwork as INetSchema;INetWeight ipNetWeight = ipNetSchema.get_WeightByName(WeightName);INetSolverWeights ipNetSolverWeights = ipTraceFlowSolver as INetSolverWeights;ipNetSolverWeights.FromToEdgeWeight = ipNetWeight;//开始边线的权重ipNetSolverWeights.ToFromEdgeWeight = ipNetWeight;//终止边线的权重object[] vaRes = new object[intCount - 1];ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinSum, out m_ipEnumNetEID_Junctions, out m_ipEnumNetEID_Edges, intCount - 1, ref vaRes); m_dblPathCost = 0;for (int i = 0; i < vaRes.Length; i++)//计算元素成本{double m_Va = (double)vaRes[i];m_dblPathCost = m_dblPathCost + m_Va;}m_ipPolyline = null;}catch { }}//初始化几何网络和地图private bool InitializeNetworkAndMap(IFeatureDataset FeatureDataset){IFeatureClassContainer ipFeatureClassContainer;IFeatureClass ipFeatureClass;IGeoDataset ipGeoDataset;。

相关文档
最新文档