欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOCX文档下载  

    GIS课程设计(开发) 本科实验报告--ArcEngine二次开发实验:地物分类统计.docx

    • 资源ID:6711893       资源大小:123.86KB        全文页数:18页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    GIS课程设计(开发) 本科实验报告--ArcEngine二次开发实验:地物分类统计.docx

    本科生实验报告实验课程GlS课程设计(开发)摘要针对GIS空间分析与建模课程讲授的基本算法设计和软件使用要求,本实验报告分别就多边形裁剪线段、多边形裁剪多边形、点与线的关系判断、泰森多边形的构建、求解最短路径等重要空间分析算法和提取中心线等进行了上机实验,通过实验对这些空间分析算法的基本思想、算法分析及算法实现过程有了更深入的理解。从理论和实践角度加深了对GlS空间分析与建模课程的认知程度,学会了如何分析现实的GIS问题及设计相应的数据结构和算法来解决问题。关键词:空间分析、算法、裁剪、多边形、线、点、tin、最短路径目录ArCEngine二次开发实验:地物分类统计1-实验目的1二 .实验内容1三 .地物分类统计技术流程13.1 算法思想及算法流程图13.2 关键代码23.3 3算法实现17四 .实验总结18ArCEngine二次开发实验:地物分类统计实验目的(1)熟练搭建ArCEngine开发环境,了解ArCEngine和ArCObjeCtS相关接口和实体类(2)利用ArCEngine实现地物分类统计,缓冲区运算,拓扑运算和地图导出等功能(3)进一步熟悉ArCEngine开发接口以及高级功能,加深对GIS空间分析和空间统计的理解二.实验内容利用C#语言、VS开发工具、ArCEngine开发平台实现地物分类统计三.地物分类统计技术流程3.1算法思想及算法流程图算法基本思想:(1)二次开发Com组件TTool,分别是用于线统计和面统计两类的工具(2)数据输入及相关初始化,选择统计工具(3)如果统计工具是面统计,则获取地图控件的轨迹多边形,否则就是线统计,获取地图控件的轨迹线,并对线做35的缓冲区。使用IElement接口绘图,然后使用IActivView导出地图(4)使用TQueryFilter进行空间查询,然后使用IDataStatiStiCS接口统计地类名称字段的值集合(5)遍历上步中的值集合,每个迭代中通过值构造SqI语句Where条件”地类名称二值”,同时结合(3)步中的轨迹多边形或者缓冲区,运用ISPatialFilter进行空间查询。遍历每个要素,统计该要素与轨迹多边形或缓冲区的相交图形的距离,从而得出每类地物的面积(6)使用IArea求出轨迹多边形或者缓冲区的总面积(7)相关结果可视化展示(8)算法结束算法流程图:图1地物分类统计流程图3.2关键代码实现该算法的核心代码如下:统计工具:/<summary>/SummarydescriptionforStaticTool./</summary>Guid(*0428808a-4782-4f8l-ab3-93be6e9226dc*)Classinterface(ClasslnterfaceType.None)ProgId(wGisStatistics.Com.StaticTool*)publicsealedclassPolygonStaticTool:BaseTool(#regionCOMRegistrationEunction(s)ComRegisterFunctionOComVisible(false)staticvoidRegisterFunction(TyperegiSterType)(/RequiredforArcGISComponentCategoryRegistrarsupportArcGISCategoryRegistration(registerType);/TODO:AddanyCOMregistrationcodehere/)ComUnregiSterFunctionOComVisible(false)staticvoidUnregisterFunction(TyperegiSterType)/RequiredforArcGISComponentCategoryRegistrarsupportArcGlSCategoryUnregistration(registerType);/TODO:AddanyCOMunregistrationCodehere/#regionArcGISComponentCategoryRegistrargeneratedcodeIII<suary>/RequiredmethodforArcGISComponentCategoryregistration-/Donotmodifythecontentsofthismethodwiththecodeeditor.Ill</summary>privatestaticvoidArcGISCategoryRegistration(TyperegiSterType)(stringregKey=string.Format(*HKEY_CLASSES_ROOTCLSID0",regiSterType.GUID);MxCommands.Register(regKey);ControlsCommands.RegisterCregKey);/<summary>/RequiredmethodforArcGISComponentCategoryunregistration-/Donotmodifythecontentsofthismethodwiththecodeeditor./</summary>privatestaticvoidArcGlSCategoryUnregistration(TyperegisterTye)(stringregKey=string.Format(*IIKEY_CLASSES_ROOTCLSID0*,registerType.GUID);MxCommands.UnregisterCregKey);ControlsCommands.Unregister(regKey);)ftendregionSendregionprivateIUookHelperm_hookllelper=null;privateIMapControl3mapControl=null;privateIToolbarControltooIBarControl=null;publicPolygonStaticToolO/TODO:Definevaluesforthepublicproperties/base.m_category=""/localizabletextbase.m_caption="面统计";/localizabletextbase.m_message="而统计";/localizabletextbase.m_toolTip="使用多边形进行统计";/localizabletextbase.m_name="面统计";/uniqueid,non-localizable(e.g.*MyCategory_MyTool*)try(/TODO:changeresourcenameifnecessary/stringbitmapResourceName=GetTypeO.Name+”.bmp"base.m_bitmap=newBitmap(GetTypeO,bitmapResourceName);base.m_cursor=newSystem.Windows.Forms.Cursor(GetTypeO,GetType().Name+”.cur");catch(Exceptionex)(System.Diagnostics.Trace.WriteLine(ex.Message,*InvalidBitmap*);)#regionOverriddenClassMethods/<summary>/Occurswhenthistooliscreated/</summary>/<paramname=*hook*>InstanceoftheappIication<param>publicoverridevoidOnCreate(objecthook)(trym_hookllelper=newHookHelperClassO;m_hookHelpcr.Hook=hook;if(m_hookllelper.ActiveView=null)m_hookHelper=null;)catchm_hookHelpcr=null;if(m_hookHelper=null)base,m-enabled=false;elsebase.m_enabled=true;/TODO:Addotherinitializationcodethis.IoolBarControl=hookasIToolbarControl;this.mapControl=this.toolBarControl.BuddyasIMapControl3;)/<suunary>/OccurswhenthistoolisclickedIII</summary>publicoverridevoidOnClickO(/TODO:AddStaticTooLOnClickimplementationthis.mapControl.CurrentTool=this;publicoverridevoidOnMouseDownCintButton,intShift,intX,intY)(/TODO:AddStaticTool.OnMouseDownimplementationif(Button=1)!GeometrypGeometry=this.mapControl.TrackPolygonO;SymbolUtil.InsertNormalLineElement(mapControl,TopologicOpreatorUtil.GetGeometryBoundary(PGeometry),255,O,O);newStatisForm(pGeometry,this.mapControl,OutputImage(pGeometry).ShowDialogO;SymbolUtil.ClearElement(mapContro1);)privatevoidOutPutArea(!GeometrypGeometry)(ITopologicalOperatorpTopoIogicOperator=pGeometryasITopologicalOperator;PTopologicOperator.Simplify();/pTopoIogicOperator.ClipIActiveViewpActiveView=this.mapControlasIActiveView;/PicturcBoxp=newPictureBoxO;/pActiveView.OutputO;)publicOVerridevoidOnMouseMove(intButton,intShift,intX,intY)/TODO:AddStaticTool.OnMouseMoveimplementationpublicoverridevoidOnMouseUp(intButton,intShift,intX,intY)(/TODO:AddStaticTool.OnMouseUp加PIementatiOnprivateImageOutputImage(!GeometrypGeometry)return MapImageUtil. SaveCurrentToImagc(mapControl. Map,331,151,pGeometry.Envelope);#endregionIII<sumary>/SummarydescriptionforPolylineStaticTool.Ill</summary>Guid(*62751d8d-07b3-4d84-a559-5ebdafbb4e0e*)Classinterface(ClassInterfaceType.None)ProgId("GisStatistics.Com.PolylineStaticTool*)ublicsealedclassPolylineStaticTool:BaseToolregionCOMRegistrationFunction(s)ComRegisterFunction()ComVisible(false)staticvoidRegisterFunction(TyperegiSterType)(/RequiredforArcGISComponentCategoryRegistrarsupportArcGisCategoryRegistration(FegisterType);/TODO:AddanyCOMregistrationcodehereComUnregiSterFunction()ComVisible(false)staticvoidUnregisterFunction(TyperegiSterType)(/RequiredforArcGISComponentCategoryRegistrarsupportArcGlSCategoryUnregistration(registerType);/TODO:AddanyCOMunregistrationcodehere/#regionArcGISComponentCategoryRegistrargeneratedcodeIII<summary>/RequiredmethodforArcGISComponentCategoryregistration-/Donotmodifythecontentsofthismethodwiththecodeeditor./</summary>privatestaticvoidArcGISCategoryRegistration(TyperegiSterType)(stringregKey=string.Format("HKEY_CLASSES_ROOTCLSID0registerType.GUID);MxCounands.Register(regKey);ControlsCominands.Register(regKey);/<sumary>/RequiredmethodforArcGISComponentCategoryunregistration-IIIDonotmodifythecontentsofthismethodwiththecodeeditor./</summary>privatestaticvoidArcGlSCategoryUnregistration(TyperegiSterType)(stringregKey=string.Format(*IIKEY_CLASSES_ROOTCLSID0)*,regiSterType.GUID);MxCommands.Unregister(regKey);ControlsCommands.Unregister(regKey);#CndregionftendregionprivateIHookHelperm_hookllelper=null;privateIMapControl3mapControl=null;privateIToolbarControltooIBarControl=null;publicPolylineStaticToolO(/TODO:Definevaluesforthepublicproperties/base.m_category=""/localizabletextbase.m_caption="线统计";/localizabletextbase,mJneSSage="线统计";/localizabletextbase.m_toolTip="使用线段缓冲区进行统计";/localizabletextbase.m_name="线统计";/uniqueid,non-localizable(e.g.*MyCategory-MyToo1*)try(/TODO:changeresourcenameifnecessary/stringbitmapResourceName=GetTypeO.Name+”.bmp"base.m_bitmap-newBitmap(GetTypeO,bitmapResourceName);base.m_cursor=newSystem.Windows.Forms.Cursor(GetTypeO,GetType().Name+”.cur*);catch(Exceptionex)(System.Diagnostics.Trace.WriteLine(ex.Message,*InvalidBitmap*);#regionOverriddenClassMethods/<summary>/Occurswhenthistooliscreated/</summary>/<paramname=*hook*>Instanceoftheapplication<param>publicoverridevoidOnCreate(objecthook)try(m_hookllelper=newHookHelperClassO;m_hookHelper.Hook=hook;if(m_hookHelper.ActiveView=null)(m_hookllelper=null;catch(m-hook11elper=null;)if(m-hookHelper=null)base.m_enabled=false;elsebase.m_enabled=true;/TODO:Addotherinitializationcodethis,tooIBarControl-hookasIToolbarControl;this.mapControl=this.toolBarControl.BuddyasIMapControl3;III<summary>IIIOccurswhenthistoolisclicked/</summary>publicoverridevoidOnClickO(/TODO:AddPolylineStaticTool.OnClickimplementationpublicOVerridevoidOnMouseDown(intButton,intShift,intX,intY)(/TODO:AddPolylineStaticTool.OnMouseDownimplementationif(Button=1)!GeometrypGeometry=this.mapControl.TrackLineO;ITopologicalOperatorTooOreator=pGeometryasITopologicalOperator:!GeometrynewGeometry=pTopoOpreator.Buffer(35);SymbolUtil.InsertNormalLineElement(mapControl,pGeometry,255,O,O);SymbolUtil.InsertNormalLineElement(mapControl,TopologicOpreatorUti1.GetGeometryBoundary(newGeometry),O,255,O);newStatisForm(newGeometry,this.mapControl,OutputImage(pGeometry).ShowDialogO;SymbolUtil.ClearElement(mapContro1);)publicoverridevoidOnMouseMove(intButton,intShift,intX,intY)(/TODO:AddPolylineStaticTool.OnMouseMoveimplementationpublicoverridevoidOnMouseUp(intButton,intShift,intX,intY)/TODO:AddPolylineStaticTool.OnMouseUpimplementation)#CndregiOnprivateImageOutputImagedGeometrypGeometry)(returnMapImageUtiLSaveCurrentToImage(mapControl.Map,331,151,pGeometry.Envelope);核心统计类:III<sumary>/空间查询与操作都助类Ill2015/12/11fhr/</summary>classFeatureDealUtilpublicstaticboolUpdateFeature(IList<IFeature>pfeatuers,DataTabledataTable)(for(inti=0;i<dataTable.Rows.Count;i+)(!FeaturepFeature=pfeatuersi;DataRowdRow=dataTable.Rowsi;boolisUpdate=false;for(intj=0;j<dRow.ItemArray.CountO;j+)(IFieldpField=pFeature.Fields.get_Field(j);if(!pField.Editable)(continue;)if(pField.Type=esriFieldType.CsriFieldTypeBlobpField.Type=esriFie1dType.esriFie1dTypeRasterIpField.Type=esriFie1dTye.esriFie1dTypeGeometry)(continue;)if(pFeature.get_Value(j)!=dRowj)(isUpdate=true;objectValUe=dRowj;if(pFeature.Fields.get-Field(j).CheckValue(value)(pFeature.set_Value(j,value);)if(isUpdate)pFeature.StoreO;returntrue;/<summary>/统计某一段各值的个数/</summary>/<paramname=*layer*X/param>III<paramname=wfieldNamc,r></param>/<returns></returns>publicstaticIDictionary<string,Int32>QueryLayercountForUnikevaluesdFeatureLayerlayer,stringfieldName,!GeometrypGeometry)(IDictionary<string,int>result=newDictionary<string,int>();IList<object>values=GetUnikeValues(layer,fieldName);foreach(stringvalueinvalues)stringwhere=string.Format(*0=,1,*,fieldName,value);Int32count=GetLayerCount(layer,pGeometry,where,fieldName);result.Add(value,count);returnresult;)publicstaticIDictionary<string,double>QueryLayerAreaForUnikevaluesdFeatureLayerlayer,stringfieldName,!GeometrypGeometry)(IDictionary<string,double>result=newDictionary<string,double>();IList<object>values=GetUnikeValues(layer,fieldName);foreach(stringvalueinvalues)(stringwhere=string.Format(*0='1,*,fieldName,value);doublecount=GetLayerClipAreadayer,pGeometry,where,fieldName);result.Add(value,count);)returnresult;publicstaticIList<object>GetUnikeValuesdFeatureLayerlayer,stringfieldName)(IList<object>values=newList<object>();IFeatureCursorFeatureCursor=QueryFeatureInLayerdayer,"");IDataStatistics(IataStatistics=newDatastatisticsClassO;(IataStatistics.Cursor=pFeatureCursoras!Cursor;dataStatistics.Field=fieldName;/IStatisticsResultsresult=dataStatistics.Statistics;!EnumeratormyEnumerator=dataStatistics.UniqueValues;List<string>myValueList=newList<string>();myEnumerator.ResetO;while(myEnumerator.MoveNextO)if(myEnumerator.Current!=null)values.Add(myEnumerator.Current.ToStringO);/IStatisticsResultsresult=dataStatistics.Statistics;returnvalues;publicstaticInt32GetLayerCount(IFeatureLayerlayer,!GeometrypGeometry,stringwhere,stringfieIdName)!CursorPCursor=QueryFeatureInLayer(layer,pGeometry,where)as!Cursor;/returnGetLayerCount(pCursor,fiel<JName);returnGetLayerCount(pCursor);)publicstaticdoubleGetLayerClipArea(IFeatureLayerlayer,!GeometrypGeometry,stringwhere,stringfieldName)(!CursorpCursor=QueryFeatureInLayer(1ayer,pGeometry,where)as!Cursor;/returnGetLayerCount(pCursor,fieldName);returnGetLayerC1ipArea(pCursor,pGeometry);)publicstaticInt32GetLayerCount(!CursorpCursor,stringfieldName)(IDataStatisticsdataStatistics=newDatastatisticsClassO;dataStatistics.SimpleStats=true;dataStatistics.Cursor=pCursor;dataStatistics.Field=fieldName;IStatisticsResultsPStatiStiCSReSUIt=dataStatistics.Statistics;returnpStatisticsResult.Count;publicstaticInt32GetLayerCount(!CursorpCursor)(intcount=O;IFeatureCursorcursor=pCursorasIFeatureCursor;while(cursor.NextFeatureO!=null)(count+;returncount;publicstaticdoubleGetLayerClipArea(!CursorpCursor,!GeometryoriginGeo)doublearea=0;IFeatureCursorcursor=pCursorasIFeatureCursor;!FeaturepFeature=cursor.NextFeatureO;while(pFeature!=null)ITopologicalOperatorpTopo=pFeature.ShapeasITopologicalOperator;!Geometrygeometry=pTopo.Intersect(originGeo,esriGeometryDimension.esriGeometry2Dimension);area+=(geometryas!Area).Area;pFeature=cursor.NextFeatureO;)returnarea;)III<suary>/利用语句进行查询返回游标和查询过滤类/</summary>/<paramname=wfeatureLayer*></param>/<paramname=wwhereClause*></param>/<returns></returns>publicstaticIFeatureCursorQueryFeatureInLayerdFeatureLayerfeatureLayer,StringWhereClause)(IFeatureCursorfeatureCursor=null;IQueryFilter2queryFiIter=newQueryFilterClassO;queryFiIter.WhereClause=WhereClause;IFeatureClassfeatureclass=featureLayer.FeatureClass;featureCursor=featureclass.Search(queryFiIter,false);returnfeatureCursor;)III<summary>/利用语句进行查询返回游标和查询过滤类/<summary>/<paramname=z,featureLayer*><param>/<paramname=*whereClause*><para>/<paramname=z,queryFi1terCopy*></param>/<returns></returns>publicstaticIFeatureCursorQueryFeatureInLayerdFeatureLayerfeatureLayer,StringWhereClause,refIQueryFilterqueryFiIterCopy)(IFeatureCursorfeatureCursor=null;IQueryFiIter2queryFiIter=newQueryFiiterClassO;queryFiIter.WhcreClause=whereClause;IFeatureClassFeatureClass=featureLayer.FeatureClass;featureCursor=featureClass.Search(queryFi1ter,false);queryFiIterCopy=queryFilter;returnfeatureCursor;/<sumary>/利用空间位置进行查询返回游标和查询过滤类/</summary>/<paramname=*featureLayer*></param>/<paramname=*geometry*></param>/<paramname="queryFiIterCopy"><Param>/<returns></returns>publicstaticIFeatureCursorQueryFeatureInLayerdFeatureLayerfeatureLayer,!Geometrygeometry,refIQueryFilterqueryFiIterCopy)(IFeatureCursorfeatureCursor=null;ISpatialFilterSpatialFilter=newSpatialFilterO;switch(featureLayer.FeatureClass.ShapeType)caseesriGeometryType.esriGeometryPoint:SpatialFilter.SpatialRel=esriSpatia1Re1Enum.esriSpatialRelContains;break;caseesriGeometryTye.esriGeometryPolyline:SpatialFilter.SpatialRel=esriSatialRelEnun.esriSpatialRelIntersects;break;caseesriGeometryType.esriGeometryPolygon:SpatialFilter.SpatialRel=esriSatialRelEnu

    注意事项

    本文(GIS课程设计(开发) 本科实验报告--ArcEngine二次开发实验:地物分类统计.docx)为本站会员(李司机)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开