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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(精选c# ArcEngine93 实现实时显示测距结果功能.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

精选c# ArcEngine93 实现实时显示测距结果功能.docx

1、精选c# ArcEngine93 实现实时显示测距结果功能c#+ArcEngine93 实现实时显示测距结果功能利用ArcEngine实现距离量测,面积量测的功能已很简单,相信众多的ArcGIS爱好者都能写. 但单纯的实现功能总觉得欠什么.本人喜欢改代码,喜欢优化代码,在原有的功能基础上总喜欢润色,使之更好看.前一整子在玩skyline时看到 skyline 的测距功能能实时显示量测的距离,于是联想到之前自己用C#+ArcEngine 写的测距功能.何不也优化一下自己代码? 想到就做到.最近手有点痒,算练练手.废话少说,先附上效果图:说明:1.本功能的特点在于在量测的过称当中实时显示量测距离,

2、并将结果实时显示在测距上方.在显示窗体上也显示量测的总距离.要点:1. INewLineFeedback 负责画线;2. 在OnMouseDown事件中计算量测距离,并向GraphicsContainer添加线和节点的Element;3.在OnMouseUp事件中实时计算距离随鼠标移动后产生的新距离.4. 将节点,量测值,线的element都分别存入到节点组和轨迹线组(IGroupElement),即用IGroupElement同一管理这些element; 最后将这些groupelement又添加到一个总的groupelement.这样做的目的在于好控制这些element,特别是启动新的量测或

3、取消量测功能时可以控制这些element,而不必去用IGraphicsContainer.DeleteAllElements来清除这些element,使用IGraphicsContainer.DeleteAllElements会将所有的element删除.5. 量测值element 为ITextElement, 由于他停靠在轨迹线的上方,因此需要对量测值element进行一定角度的旋转,旋转角度由轨迹线的方向角决定.6. 绘制element之后的刷新问题也是比较重要的. 刷新范围一定要控制好,太小了,添加的element显示不出来,太大了,浪费. (实在不好控制就刷新整个extent吧,呵呵)

4、核心代码如下:1. TrackLine类TrackLine/=功能测距=/描述:实时显示测量距离,节点位置,总长度/编程:Jin开发时间:2009.8.10-2009.8.11/特点:实时计算量测距离./缺点:由于采用element做为显示内容,地图进行放大缩小操作后并不能很好/控制量测值element和轨迹线element之间的距离间隔./=usingSystem;usingSystem.Drawing;usingSystem.Runtime.InteropServices;usingESRI.ArcGIS.ADF.BaseClasses;usingESRI.ArcGIS.ADF.CATID

5、s;usingESRI.ArcGIS.Controls;usingESRI.ArcGIS.Carto;usingESRI.ArcGIS.Geodatabase;usingESRI.ArcGIS.Display;usingESRI.ArcGIS.Geometry;usingSystem.Windows.Forms;namespaceMhGis.GisTool.Pb_ToolbarclassTrackLine:BaseToolprivateIHookHelperm_hookHelper=null;privateINewLineFeedbackm_NewLineFeedback=null;priva

6、teIPointCollectionm_ptColl;/记录节点privateMeasureMsgInfo_MsgInfo=null;privateIPolylinem_TraceLine=null;/完整的轨迹线/privateIGroupElementm_Elements=null;/用于保存包含此功能产生的所有ElementprivateIGroupElementm_TraceElement=null;/测距轨迹线privateIGroupElementm_VertexElement=null;/结点privateIGroupElementm_LabelElement=null;/距离标

7、记publicTrackLine()/TODO:Definevaluesforthepublicproperties/base.m_category=;/localizabletextbase.m_caption=;/localizabletextbase.m_message=ThisshouldworkinArcMap/MapControl/PageLayoutControl;/localizabletextbase.m_toolTip=;/localizabletextbase.m_name=;/uniqueid,non-localizable(e.g.MyCategory_MyTool)

8、try/TODO:changeresourcenameifnecessary/stringbitmapResourceName=GetType().Name+.bmp;base.m_bitmap=newBitmap(GetType(),bitmapResourceName);base.m_cursor=newSystem.Windows.Forms.Cursor(GetType(),GetType().Name+.cur);catch(Exceptionex)System.Diagnostics.Trace.WriteLine(ex.Message,InvalidBitmap);publicM

9、easureMsgInfoMsgInfoset_MsgInfo=value;_MsgInfo.FormClosing+=newFormClosingEventHandler(msgInfo_FromClosing);#regionOverridenClassMethods/Occurswhenthistooliscreated/InstanceoftheapplicationpublicoverridevoidOnCreate(objecthook)trym_hookHelper=newHookHelperClass();m_hookHelper.Hook=hook;if(m_hookHelp

10、er.ActiveView=null)m_hookHelper=null;catchm_hookHelper=null;if(m_hookHelper=null)base.m_enabled=false;elsebase.m_enabled=true;/TODO:AddotherinitializationcodevoidInit()/初始化m_Elements=newGroupElementClass();m_TraceElement=newGroupElementClass();m_VertexElement=newGroupElementClass();m_LabelElement=ne

11、wGroupElementClass();/初始化,并添加到GraphicsContainerIGraphicsContainerg=m_hookHelper.ActiveViewasIGraphicsContainer;g.AddElement(m_ElementsasIElement,0);g.AddElement(m_TraceElementasIElement,0);g.AddElement(m_VertexElementasIElement,0);g.AddElement(m_LabelElementasIElement,0);/添加到m_Elements中g.MoveElement

12、ToGroup(m_VertexElementasIElement,m_Elements);g.MoveElementToGroup(m_LabelElementasIElement,m_Elements);g.MoveElementToGroup(m_TraceElementasIElement,m_Elements);/Occurswhenthistoolisclicked/publicoverridevoidOnClick()Init();voidmsgInfo_FromClosing(objectsender,FormClosingEventArgse)DeleteAllElement

13、s();_MsgInfo=null;/thrownewException(Themethodoroperationisnotimplemented.);publicoverridevoidOnMouseDown(intButton,intShift,intX,intY)if(Button=2)return;IPointpt=m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X,Y);IGraphicsContainerg=m_hookHelper.ActiveView.GraphicsContainer

14、;IEnvelopepEnvBounds=null;/获取上一次轨迹线的范围,以便确定刷新范围tryif(m_TraceLine!=null)m_TraceLine.QueryEnvelope(pEnvBounds);pEnvBounds.Expand(4,4,true);/矩形框向四周扩大4倍(大于2倍就行),目的是为了保证有充足的刷新区域elsepEnvBounds=m_hookHelper.ActiveView.Extent;catchpEnvBounds=m_hookHelper.ActiveView.Extent;#region启动画线if(m_NewLineFeedback=nul

15、l)/移除elementRemoveElements();/刷新m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);Application.DoEvents();m_NewLineFeedback=newNewLineFeedbackClass();m_NewLineFeedback.Display=m_hookHelper.ActiveView.ScreenDisplay;/必须先得到symbol,后设置symbolISimpleLineSymbolsimpleLineSym

16、bol=m_NewLineFeedback.SymbolasISimpleLineSymbol;simpleLineSymbol.Style=esriSimpleLineStyle.esriSLSDot;simpleLineSymbol.Width=1;simpleLineSymbol.Color=TransColorToAEColor(Color.Blue);m_NewLineFeedback.Start(pt);elsem_NewLineFeedback.AddPoint(pt);if(m_ptColl=null)m_ptColl=newPolylineClass();/记录节点objec

17、tobj=Type.Missing;m_ptColl.AddPoint(pt,refobj,refobj);#endregion#region绘制结点tryIElementvertexElement=CreateElement(pt);/g=m_hookHelper.ActiveViewasIGraphicsContainer;/g.AddElement(vertexElement,0);/g.MoveElementToGroup(vertexElement,m_VertexElement);m_VertexElement.AddElement(vertexElement);/刷新m_hook

18、Helper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,vertexElement,pEnvBounds);catch#endregiontryif(m_ptColl.PointCount=2)IPointfromPt=m_ptColl.get_Point(m_ptColl.PointCount-2);/倒数第二个点IPointtoPt=m_ptColl.get_Point(m_ptColl.PointCount-1);/最后第一个点ILineline=newLineClass();line.PutCoords(f

19、romPt,toPt);#region绘制轨迹线tryobjectmissing=Type.Missing;ISegmentCollectionsegColl=newPolylineClass();segColl.AddSegment(lineasISegment,refmissing,refmissing);IElementtraceElement=CreateElement(segCollasIPolyline);/g=m_hookHelper.ActiveViewasIGraphicsContainer;/g.AddElement(traceElement,0);/g.MoveEleme

20、ntToGroup(traceElement,m_TraceElement);m_TraceElement.AddElement(traceElement);m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,traceElement,pEnvBounds);catch#endregion#region计算单线的长度,并将结果显示在单线中点偏上上面trydoubleangle=line.Angle;if(angle(Math.PI/2)&angle-Math.PI&angle-(Math.PI/2)/

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

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