ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:819.57KB ,
资源ID:29604707      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/29604707.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(GIS软件工程实习报告材料最短路径分析报告.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

GIS软件工程实习报告材料最短路径分析报告.docx

1、GIS软件工程实习报告材料最短路径分析报告AE开发之基于几何网络的最短路径分析1、实习目的本次实习目的在于熟练掌握ArcGIS Engine开发工具并能够通过C#语言在VS 2010开发环境中完成查询几何网络的最短路径分析的功能。2、实习时间2015年5月23日星期六3、实习内容3.1实验环境操作系统:Windows 2007二次开发平台:VS 2010开发环境、ArcGIS Desktop10.0、AE开发组件3.2实验任务完成基于几何网络分析的最短路径查询功能,即实现通过在几何网络地图中指定起始点,能够查询经过起始点的最短路线,并能够通过缩放功能在地图窗口居中显示。3.3实验步骤3.3.1

2、新建项目选择文件新建项目,如图选择项目类型中Visual C#,再选择Windows Application,记为“FindShortPath”,点击确定。3.3.2添加控件3.3.3控件绑定因为添加的控件只是单独存在,但是程序需要各控件间协同工作,因此要进行控件绑定。3.3.4创建几何网络1.在ArcCataLog中新建个人地理数据库“甘地的个人地理数据库”,然后新建要素数据集“road”,接着,鼠标右键选择要素数据集“road”,选择“导入要素类”,导入需要创建几何网络的要素类“主要公路”,输出要素类的名字改为“road”,如下图所示:2.鼠标右键选择要素数据集“road”,选择新建“几何

3、网络”,则出现“新建几何网络”对话框,作如下图所示的一系列设置,最终得到几何网络“road_Net”。 至此,得到几何网络“road_Net”,如下图所示:3.3.5代码实现最短路径分析1设置ToolStrip12添加代码privateIActiveViewm_ipActiveView; private IMapm_ipMap;/地图控件中地图 private IGraphicsContainerpGC;/图形对象privatebool clicked = false;intclickedcount = 0; private double m_dblPathCost = 0; private

4、IGeometricNetworkm_ipGeometricNetwork; private IPointCollectionm_ipPoints;/输入点集合privateIPointToEIDm_ipPointToEID; private IEnumNetEIDm_ipEnumNetEID_Junctions; private IEnumNetEIDm_ipEnumNetEID_Edges; private IPolylinem_ipPolyline;private IMapControl3 mapctrlMainMap = null;private void Form1_Load(obj

5、ect sender, EventArgs e) /对象初始化mapctrlMainMap = (IMapControl3)this.axMapControl1.Object;m_ipActiveView = axMapControl1.ActiveView;m_ipMap = m_ipActiveView.FocusMap;clicked = false;pGC = m_ipMap as IGraphicsContainer; private void Findpath_Click(object sender, EventArgs e) mapctrlMainMap.CurrentTool

6、= null; /设置鼠标样式 axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;if (axMapControl1.LayerCount = 0) MessageBox.Show(请先加载几何网络数据!);return; m_ipActiveView = axMapControl1.ActiveView;m_ipMap = m_ipActiveView.FocusMap;clicked = false;pGC = m_ipMap as IGraphicsContainer;ILayeripLa

7、yer = m_ipMap.get_Layer(0);IFeatureLayeripFeatureLayer = ipLayer as IFeatureLayer;IFeatureDatasetipFDS = ipFeatureLayer.FeatureClass.FeatureDataset;OpenFeatureDatasetNetwork(ipFDS);clicked = true;clickedcount = 0;pGC.DeleteAllElements(); private void SolvePath_Click(object sender, EventArgs e) axMap

8、Control1.MousePointer = esriControlsMousePointer.esriPointerDefault; if (SolvePathGan(Weight)/先解析路径 IPolylineipPolyResult = PathPolyLine();/最后返回最短路径clicked = false;if (ipPolyResult.IsEmpty) MessageBox.Show(没有路径可到!); else IRgbColor color = new RgbColorClass();color.Red = 255;color.Blue = 64;color.Gre

9、en = 128;LineElementClass element = new LineElementClass();ILineSymbollinesymbol = new SimpleLineSymbolClass();linesymbol.Color = color as IColor;linesymbol.Width = 3;element.Geometry = m_ipPolyline;element.Symbol = linesymbol;pGC.AddElement(element, 0); m_ipActiveView.PartialRefresh(esriViewDrawPha

10、se.esriViewGraphics, null, null);axMapControl1.FlashShape(element.Geometry);MessageBox.Show(路径经过 + m_ipEnumNetEID_Edges.Count + 条线 + rn + 经过节点数为 + m_ipEnumNetEID_Junctions.Count + rn + 路线长度为 + m_ipPolyline.Length.ToString(#.#) + rn, 几何路径信息); /路径缩放功能private void SuoFang_Click(object sender, EventArgs

11、 e) if (m_ipPolyline = null) MessageBox.Show(当前没有执行路径查询!请确认!); else this.axMapControl1.Extent = m_ipPolyline.Envelope; #region 自定义路径查询函数public void OpenFeatureDatasetNetwork(IFeatureDatasetFeatureDataset) CloseWorkspace();if (!InitializeNetworkAndMap(FeatureDataset)Console.WriteLine(打开network出错); /关

12、闭工作空间private void CloseWorkspace() m_ipGeometricNetwork = null;m_ipPoints = null;m_ipPointToEID = null;m_ipEnumNetEID_Junctions = null;m_ipEnumNetEID_Edges = null;m_ipPolyline = null; /初始化几何网络和地图privateboolInitializeNetworkAndMap(IFeatureDatasetFeatureDataset) IFeatureClassContaineripFeatureClassCon

13、tainer;IFeatureClassipFeatureClass;IGeoDatasetipGeoDataset;ILayeripLayer;IFeatureLayeripFeatureLayer;IEnvelopeipEnvelope, ipMaxEnvelope;doubledblSearchTol;INetworkCollectionipNetworkCollection = FeatureDataset as INetworkCollection;int count = ipNetworkCollection.GeometricNetworkCount; /获取第一个几何网络工作空

14、间m_ipGeometricNetwork = ipNetworkCollection.get_GeometricNetwork(0);INetworkipNetwork = m_ipGeometricNetwork.Network;if (m_ipMap != null) ipFeatureClassContainer = m_ipGeometricNetwork as IFeatureClassContainer;count = ipFeatureClassContainer.ClassCount;for (int i = 0; i count; i+) ipFeatureClass =

15、ipFeatureClassContainer.get_Class(i);ipFeatureLayer = new FeatureLayerClass();ipFeatureLayer.FeatureClass = ipFeatureClass;for (int j = 0; j m_ipMap.LayerCount; j+) if (m_ipMap.get_Layer(j).Name.ToUpper() = ipFeatureLayer.Name.ToUpper() continue; count = m_ipMap.LayerCount;ipMaxEnvelope = new Envelo

16、peClass();for (int i = 0; i dblHeight)dblSearchTol = dblWidth / 100;elsedblSearchTol = dblHeight / 100;m_ipPointToEID.SnapTolerance = dblSearchTol;return true; /返回路径的几何体publicIPolylinePathPolyLine() IEIDInfoipEIDInfo;IGeometryipGeometry;if (m_ipPolyline != null) return m_ipPolyline;m_ipPolyline = ne

17、w PolylineClass();IGeometryCollectionipNewGeometryColl = m_ipPolyline as IGeometryCollection;/引用传递ISpatialReferenceipSpatialReference = m_ipMap.SpatialReference;IEIDHelperipEIDHelper = new EIDHelper();ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork;ipEIDHelper.OutputSpatialReference = ipSpatialR

18、eference;ipEIDHelper.ReturnGeometries = true;IEnumEIDInfoipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_ipEnumNetEID_Edges);int count = ipEnumEIDInfo.Count;ipEnumEIDInfo.Reset();for (int i = 0; i count; i+) string info;info = new stringcount;ipEIDInfo = ipEnumEIDInfo.Next();ipGeometry = ipEIDInfo.G

19、eometry;ipNewGeometryColl.AddGeometryCollection(ipGeometry as IGeometryCollection);infoi = m_ipPolyline.Length.ToString(); returnm_ipPolyline; publicboolSolvePathGan(string WeightName) try intintJunctionUserClassID;intintJunctionUserID;intintJunctionUserSubID;intintJunctionID;IPointipFoundJunctionPo

20、int;ITraceFlowSolverGENipTraceFlowSolver = new TraceFlowSolver() as ITraceFlowSolverGEN;INetSolveripNetSolver = ipTraceFlowSolver as INetSolver;if (m_ipGeometricNetwork = null) return false; INetworkipNetwork = m_ipGeometricNetwork.Network;ipNetSolver.SourceNetwork = ipNetwork;INetElementsipNetEleme

21、nts = ipNetwork as INetElements;if (m_ipPoints = null) MessageBox.Show(请选择点!); return false; intintCount = m_ipPoints.PointCount;/这里的points有值吗? /定义一个边线旗数组 /*最近点*/IJunctionFlag pJunctionFlagList = new JunctionFlagintCount;for (int i = 0; i intCount; i+) INetFlagipNetFlag = new JunctionFlag() as INetF

22、lag;IPointipJunctionPoint = m_ipPoints.get_Point(i); /查找输入点的最近的网络点m_ipPointToEID.GetNearestJunction(ipJunctionPoint, out intJunctionID, out ipFoundJunctionPoint);ipNetElements.QueryIDs(intJunctionID, esriElementType.esriETJunction, out intJunctionUserClassID, out intJunctionUserID, out intJunctionUs

23、erSubID);ipNetFlag.UserClassID = intJunctionUserClassID;ipNetFlag.UserID = intJunctionUserID;ipNetFlag.UserSubID = intJunctionUserSubID;IJunctionFlagpTemp = (IJunctionFlag)(ipNetFlag as IJunctionFlag);pJunctionFlagListi = pTemp; ipTraceFlowSolver.PutJunctionOrigins(ref pJunctionFlagList);INetSchemai

24、pNetSchema = ipNetwork as INetSchema;INetWeightipNetWeight = ipNetSchema.get_WeightByName(WeightName);INetSolverWeightsipNetSolverWeights = ipTraceFlowSolver as INetSolverWeights;ipNetSolverWeights.FromToEdgeWeight = ipNetWeight;/开始边线的权重ipNetSolverWeights.ToFromEdgeWeight = ipNetWeight;/终止边线的权重objec

25、t vaRes = new objectintCount - 1; /通过findpath得到边线和交汇点的集合ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected,esriShortestPathObjFn.esriSPObjFnMinSum,outm_ipEnumNetEID_Junctions, out m_ipEnumNetEID_Edges, intCount - 1, ref vaRes);m_dblPathCost = 0;for (int i = 0; i vaRes.Length; i+) doublem_Va =

26、 (double)vaResi;m_dblPathCost = m_dblPathCost + m_Va; m_ipPolyline = null;return true; catch (Exception ex) Console.WriteLine(ex.Message); return false; #endregion private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) if (clicked != true)return;IPointipNew;if (

27、m_ipPoints = null) m_ipPoints = new Multipoint(); ipNew = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);object o = Type.Missing;m_ipPoints.AddPoint(ipNew, ref o, ref o);IElement element;ITextElementtextelement = new TextElementClass();element = textelement as IElement;click

28、edcount+;textelement.Text = clickedcount.ToString();element.Geometry = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);pGC.AddElement(element, 0); m_ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); 3.4实验结果在得到的窗口中加载“甘地的个人地理数据库”(在压缩包中有)中的几何网络“road_Ne

29、t”,将几何网络地图加载到地图显示窗口中,如下图所示:点击图标添加起始点,效果如下图:然后点击图标,计算最短路径,效果如下图:最后点击图标得到最短路径的缩放,效果如下图:这样就完成了最短路径的查询分析和显示的功能。4、实习总结在整个过程中所出现的问题较多,体现出个人基础的不足,程序的出错有时候出现在标点符号以及英文字母的大小写上面等等问题,这些都说明了不熟练的问题。因此,二次开发的一个最重要的是勤于练习敲代码,能够对着书本的代码敲二不会出现一些不该犯的错误,然后进行下一步的提高,一步一个踏实的脚印,打下一个坚实的基础是非常重要。另一个重要的体会就是学会自己去查询资料,尽可能的通过自己的能力解决问题,实在不能解决的在向老师请教

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1