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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Arcgis 功能类代码.docx

1、Arcgis 功能类代码目录:1. 打点,Element类 22. 清除所有元素,Element类 33. 画线,Element类 34. 根据传入的点集画面,Element类,目前没有实现 45. 在图层上添加点,feature类 56. 显示当前选中图元属性,feature类 67. 删除当前选中图元,feature类 78. 查询图元并闪烁,feature类 89. 得到符号 910. 渲染图元,feature类 1011. 获取图片element,element类 1112. element旋转,element类 1213. 加载SHP文件 1214. 判断图形B是否包含在图形A中,f

2、eature类 1315. 获得点 1416. element沿线移动,element类 1517. 元素移动,element类 15Arcgis 功能类代码using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Display;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.DataSourcesFi

3、le;/Arcgis 功能代码 / 1.打点,Element类 / / 点的X坐标 / 点的Y坐标 private void DrawPoint(double x, double y) IActiveView activeView = this.axMapControl1.ActiveView.FocusMap as IActiveView; IElement pElement; IPoint pt = new PointClass(); pt.PutCoords(x, y); /设置点颜色 IRgbColor pColor = new RgbColorClass(); pColor.Red

4、= 255; /设置点的样式 ISimpleMarkerSymbol pSMS = new SimpleMarkerSymbolClass(); pSMS.Size = 9; pSMS.Color = pColor; pSMS.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerElement pME = new MarkerElementClass(); pME.Symbol = pSMS; pElement = pME as IElement; pElement.Geometry = pt; activeView.GraphicsCont

5、ainer.AddElement(pElement, 0); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); / 2.清除所有元素,Element类 / private void DeleteAllElements() IActiveView activeView = this.axMapControl1.ActiveView.FocusMap as IActiveView; activeView.GraphicsContainer.DeleteAllElements(); activeVie

6、w.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); / 3.画线,Element类 / / 点集 / 点集点的数目 private void DrawLine(double, pointArray, int arrayCount) if (arrayCount = 0) return; /点坐标数组不能为空 IActiveView activeView = this.axMapControl1.ActiveView.FocusMap as IActiveView; /设置颜色 IRgbColor color =

7、new RgbColorClass(); color.Red = 255; color.Blue = 255; color.Transparency = 255; /线样式 ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = color; lineSymbol.Style = esriSimpleLineStyle.esriSLSInsideFrame; lineSymbol.Width = 1; /点对象 IPoint pPoint = new PointClass(); /线元素 IL

8、ineElement lineElement = new LineElementClass(); lineElement.Symbol = lineSymbol; /线对象 IPolyline m_Polyline = new PolylineClass(); /点集合对象 IPointCollection m_PointCollection = new PolylineClass(); object missing = Type.Missing; for (int i = 0; i arrayCount; i+) pPoint.PutCoords(pointArrayi, 0, pointA

9、rrayi, 1); m_PointCollection.AddPoint(pPoint, ref missing, ref missing); m_Polyline = m_PointCollection as IPolyline; IElement element = lineElement as IElement; element.Geometry = m_Polyline; activeView.GraphicsContainer.AddElement(element, 0); activeView.PartialRefresh(esriViewDrawPhase.esriViewGr

10、aphics, null, null); / 4.根据传入的点集画面,Element类,目前没有实现 / / / private void DrawPolygon(double, pointArray, int arrayCount) ILayer pLayer = this.axMapControl1.get_Layer(0); IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFC = pFLayer.FeatureClass; /点对象 IPoint pPoint = new PointClass(); /点集

11、合对象 IPointCollection m_PointCollection = new PolylineClass(); object missing = Type.Missing; for (int i = 0; i arrayCount; i+) pPoint.PutCoords(pointArrayi, 0, pointArrayi, 1); m_PointCollection.AddPoint(pPoint, ref missing, ref missing); /由于要画面,所以polygon的最后一个点和第一个点是同一个点,因此代码多余用到图元复制,也可以把第一个点再添加一遍就可

12、以了 /把第一个点再添加一遍,此代码节俭,用这个 pPoint.PutCoords(pointArray0, 0, pointArray0, 1); m_PointCollection.AddPoint(pPoint, ref missing, ref missing); /下面这个用图元复制,不节俭,所以注释起来留待以后参考 /IClone pClone = m_PointCollection.get_Point(0) as IClone; /IPoint pEndPoint = pClone.Clone() as IPoint; /m_PointCollection.AddPoint(pE

13、ndPoint, ref missing, ref missing); IWorkspaceEdit pWE = (pFC as IDataset).Workspace as IWorkspaceEdit; pWE.StartEditing(false); pWE.StartEditOperation(); IFeature pFeature = pFC.CreateFeature(); pFeature.Shape = m_PointCollection as IPolygon; pFeature.Store(); pFeature.set_Value(pFeature.Fields.Fin

14、dField(类型), 新加图元); pFeature.Store(); pFeature.set_Value(pFeature.Fields.FindField(面积), 130); pFeature.Store(); pWE.StopEditOperation(); pWE.StopEditing(true); this.axMapControl1.ActiveView.Refresh(); / 5. 在图层上添加点,feature类 / / X坐标 / Y坐标 private void AddPointOnLayer(double x, double y) /得到要添加地物的图层 IFe

15、atureLayer iFeatureL = this.axMapControl1.Map.get_Layer(1) as IFeatureLayer; /定义一个地物类,把要编辑的图层转化为定义的地物类 IFeatureClass iFeatureC = iFeatureL.FeatureClass; /先定义一个编辑的工作空间,然后转化为数据集,最后转化为编辑工作空间 IWorkspaceEdit w = (iFeatureC as IDataset).Workspace as IWorkspaceEdit; IFeature pFeature; IPoint pPoint; /开始事务操

16、作 w.StartEditing(true); /开始编辑 w.StartEditOperation(); /创建一个地物 pFeature = iFeatureC.CreateFeature(); pPoint = new PointClass(); /设置点的坐标 pPoint.PutCoords(x, y); /确定图形类型 pFeature.Shape = pPoint; /保存地物 pFeature.Store(); pFeature.set_Value(pFeature.Fields.FindField(类别), Circle 2); pFeature.Store(); /结束编辑

17、 w.StopEditOperation(); /结束事务操作 w.StopEditing(true); this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, iFeatureL, null); / 6. 显示当前选中图元属性,feature类 / private void showAttri() string str = ; /获取图层 IQueryFilter pQueryFilter = new QueryFilterClass(); IFeatureLayer pFeature

18、Layer = this.axMapControl1.get_Layer(1) as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; int indexOfName = pFeatureClass.FindField(类别); IFeature pFeature; IMap pMap = this.axMapControl1.Map; ISelection pSelection = pMap.FeatureSelection; IEnumFeature pEnumFeature = pSelect

19、ion as IEnumFeature; pEnumFeature.Reset(); pFeature = pEnumFeature.Next(); if (pFeature = null) MessageBox.Show(未选中图元,请重新选择); else while (pFeature != null) pQueryFilter.WhereClause = FID=+pFeature.get_Value(0).ToString(); IFeatureCursor pFeatureCursor = pFeatureLayer.Search(pQueryFilter, true); IFea

20、ture xxfeature; xxfeature = pFeatureCursor.NextFeature(); str = str + 类别:+xxfeature.get_Value(indexOfName).ToString() + n; pFeature = pEnumFeature.Next(); MessageBox.Show(str); / 7.删除当前选中图元,feature类 / private void deleteFeature() IFeature pFeature; IFeatureLayer iFeatureL = this.axMapControl1.get_La

21、yer(1) as IFeatureLayer; IFeatureClass iFeatureC = iFeatureL.FeatureClass; IWorkspaceEdit iWorkspaceE = (iFeatureC as IDataset).Workspace as IWorkspaceEdit; iWorkspaceE.StartEditing(true); iWorkspaceE.StartEditOperation(); IMap pMap = this.axMapControl1.Map; IEnumFeature pEnumFeature = pMap.FeatureS

22、election as IEnumFeature; pEnumFeature.Reset(); pFeature = pEnumFeature.Next(); try if (pFeature != null) while (pFeature != null) DialogResult pDialogR = MessageBox.Show(确实要删除FID= + pFeature.get_Value(0).ToString() + 的图元吗?, 提示:, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (pDialogR = D

23、ialogResult.Yes) pFeature.Delete(); MessageBox.Show(删除成功!); pFeature = pEnumFeature.Next(); catch (Exception err) MessageBox.Show(err.Message); iWorkspaceE.StopEditOperation(); iWorkspaceE.StopEditing(true); this.axMapControl1.ActiveView.Refresh(); / 8.查询图元并闪烁,feature类 / / 查询条件 private void FindFeat

24、ureAndShape(string sqlFilter) this.axMapControl1.Map.ClearSelection(); this.axMapControl1.ActiveView.Refresh(); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = sqlFilter; IFeatureLayer pFeatureLayer = this.axMapControl1.get_Layer(1) as IFeatureLayer; IFeatureCursor pFe

25、atureCursor = pFeatureLayer.Search(pQueryFilter, true); IFeature pFeature; pFeature = pFeatureCursor.NextFeature(); if (pFeature = null) MessageBox.Show(未找到图元!); return; ISimpleMarkerSymbol iSimpleMarker = new SimpleMarkerSymbolClass(); iSimpleMarker.Style = esriSimpleMarkerStyle.esriSMSCircle; iSim

26、pleMarker.Size = 12; this.axMapControl1.Map.SelectFeature(pFeatureLayer, pFeature); this.axMapControl1.FlashShape(pFeature.Shape as IGeometry, 5, 300, iSimpleMarker); this.axMapControl1.Map.ClearSelection(); /this.axMapControl1.ActiveView.Refresh(); / 9. 得到符号 / / 符号路径 / 符号类型 / 符号名称 / 返回指定符号 private

27、ISymbol GetSymbol(string sServerStylePath, string sGalleryClassName, string symbolName) try IStyleGallery pStyleGaller = new ServerStyleGalleryClass(); IStyleGalleryStorage pStyleGalleryStorage = pStyleGaller as IStyleGalleryStorage; IEnumStyleGalleryItem pEnumSyleGalleryItem = null; IStyleGalleryIt

28、em pStyleGallerItem = null; IStyleGalleryClass pStyleGalleryClass = null; pStyleGalleryStorage.AddFile(sServerStylePath); for (int i = 0; i pStyleGaller.ClassCount; i+) pStyleGalleryClass = pStyleGaller.get_Class(i); if (pStyleGalleryClass.Name != sGalleryClassName) continue; pEnumSyleGalleryItem = pStyleGaller.get_Items(sGalleryClassName, sServerStylePath,

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

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