为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

C#-AE-ArcGlobe-图层上画点、画线、图层矢量数据查询

2021-12-19 1页 doc 45KB 20阅读

用户头像 个人认证

rabbit

我是一名高中英语老师 有着丰厚的教学经验,曾经担任过学校教学教研组组长,撰写过很多论文和期刊

举报
C#-AE-ArcGlobe-图层上画点、画线、图层矢量数据查询如有侵权,请联系网站删除,仅供学习与交流【精品文档】第PAGE5页C#-AE-ArcGlobe-图层上画点、画线、图层矢量数据查询///C#AEArcGlobe图层上画点privatevoidtoolStripButton1_Click(objectsender,EventArgse)//首先要获取图层,也就是说你要先加载一个点图层//因为shp文件也是分点线面,而且现在画的是点,所以此时必须加载点shp文件,可以在ArcCatalog里生成shp文件ILayerpLayer=(IFeatureLayer)axGlobe...
C#-AE-ArcGlobe-图层上画点、画线、图层矢量数据查询
如有侵权,请联系网站删除,仅供学习与交流【精品文档】第PAGE5页C#-AE-ArcGlobe-图层上画点、画线、图层矢量数据查询///C#AEArcGlobe图层上画点privatevoidtoolStripButton1_Click(objectsender,EventArgse)//首先要获取图层,也就是说你要先加载一个点图层//因为shp文件也是分点线面,而且现在画的是点,所以此时必须加载点shp文件,可以在ArcCatalog里生成shp文件ILayerpLayer=(IFeatureLayer)axGlobeControl1.Globe.GlobeDisplay.Scene.get_Layer(0);IFeatureLayerpFeatureLayer=pLayerasIFeatureLayer;//转换一下,以便获取图层上的要素IFeatureClasspFeatureCls=pFeatureLayer.FeatureClass;//再定义一个要素集合,这样才能编辑,搞这么麻烦。。我也不知道为什么//用过ArcMap你就知道,要想编辑shp文件上的数据,首先要打开可编辑状态,就是下面打开工作空间IWorkspaceEditpWorkSpace=(pFeatureClsasIDataset).WorkspaceasIWorkspaceEdit;pWorkSpace.StartEditing(true);//开启编辑状态pWorkSpace.StartEditOperation();//开始编辑操作//IPointpPoint=newPointClass();////pPoint.PutCoords(22,44);//点的位置m_pGlobeDisplay=axGlobeControl1.Globe.GlobeDisplay;//IPointpPoint=GlobeUtility.GlobeToDD(m_pGlobeDisplay,2222,1111,true);////设置点高程//GlobeUtility.MakeZAware(pPoint);//将点添加到场景IPointpPoint=GlobeUtility.GlobeToDD(m_pGlobeDisplay,50,50,true);if(pPoint!=null)pPoint.Z=pPoint.Z*1000;//pPoint.SpatialReference=GlobeUtil.getGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_WGS1984);//pGlobeGraphicsLayer.PutElementName(pElement,"定位点");IFeaturepPointFeature=pFeatureCls.CreateFeature();//这里要定义一个可以加到图层上的要素,这样才能加上去//但还不知道这个要素是什么呢,所以要把刚刚创建的点给赋给这个要素pPointFeature.Shape=pPoint;//好!现在这个要素的样子是点pPointFeature.Store();//将这个点要素保存下来//接下来要把要素加到图层上IFeatureClassWritepFeatClsWr=pFeatureClsasIFeatureClassWrite;//添加要素到图层的方法在IFeatureClassWrite里面pFeatClsWr.WriteFeature(pPointFeature);pWorkSpace.StopEditOperation();//前后呼应pWorkSpace.StopEditing(true);//有始有终~~IPointpPointCenter=newPointClass();//定义这个点为了设置中心位置pPointCenter.PutCoords(350,350);///C#AEArcGlobe图层上画线privatevoidtoolStripButton3_Click(objectsender,EventArgse)ILayerpLayer=(IFeatureLayer)GetGlobeLayer(m_pGlobe.GlobeDisplay.Scene,"疏散路线");IFeatureLayerpFeatureLayer=pLayerasIFeatureLayer;IFeatureClasspFeatureCls=pFeatureLayer.FeatureClass;//IWorkspaceEditw=(pFeatureClsasIDataset).WorkspaceasIWorkspaceEdit;//w.StartEditing(true);//w.StartEditOperation();ILinepLine=newLineClass();IPointfromPoint=newPointClass();fromPoint.PutCoords(50,50);IPointtoPoint=newPointClass();toPoint.PutCoords(80,80);pLine.PutCoords(fromPoint,toPoint);ILinepLine1=newLineClass();IPointfromPoint1=newPointClass();fromPoint1.PutCoords(80,80);IPointtoPoint1=newPointClass();toPoint1.PutCoords(90,100);pLine1.PutCoords(fromPoint1,toPoint1);//依然要转换为polylineobjecto=Type.Missing;ISegmentCollectionpPath=newPathClass();pPath.AddSegment((ISegment)pLine,o,o);pPath.AddSegment((ISegment)pLine1,o,o);IGeometryCollectionpPolyline=newPolylineClass();pPolyline.AddGeometry((IGeometry)pPath,o,o);IGeometrypGeometry=pPolylineasIGeometry;IFeaturepLineFeature=pFeatureCls.CreateFeature();pLineFeature.Shape=pGeometry;pLineFeature.Store();IFeatureClassWritepFeaClsWr=pFeatureClsasIFeatureClassWrite;pFeaClsWr.WriteFeature(pLineFeature);//w.StopEditOperation();//w.StopEditing(true);(m_pGlobe.GlobeDisplayasIGlobeDisplayLayers).RefreshLayer(pLayer);//获得Globe下的指定图层publicstaticILayerGetGlobeLayer(IScenepScene,stringstrLayerName)tryobjectMissing=Type.Missing;IEnumLayerpEnumLayer=pScene.get_Layers(null,false);ICompositeLayerpCompositeLayer;ILayerpLayer=pEnumLayer.Next();while(pLayer!=null)if(pLayerisIGroupLayer)pCompositeLayer=pLayerasICompositeLayer;for(inti=0;i<=pCompositeLayer.Count-1;i++)if(strLayerName.ToUpper()==pCompositeLayer.get_Layer(i).Name.ToUpper())returnpCompositeLayer.get_Layer(i);elseif(strLayerName.ToUpper()==pLayer.Name.ToUpper())returnpLayer;pLayer=pEnumLayer.Next();returnnull;catch(Exceptionex)MessageBox.Show(ex.Message);returnnull;////ArcGlobe查询矢量数据privatevoidtoolStripButton1_Click(objectsender,EventArgse)dgv.Rows.Clear();//首先要获取图层,也就是说你要先加载一个点图层//因为shp文件也是分点线面,而且现在画的是点,所以此时必须加载点shp文件,可以在ArcCatalog里生成shp文件ILayerpLayer=(IFeatureLayer)GetGlobeLayer(m_IGlobe.GlobeDisplay.Scene,"警力部署");IFeatureLayerpFeatureLayer=pLayerasIFeatureLayer;//转换一下,以便获取图层上的要素IFieldspFields;IQueryFilterpQueryFilter=newQueryFilterClass();pQueryFilter.WhereClause="\"JLYAMC\"='警力部署'";IFeatureCursorpFeatureCursor;pFeatureCursor=pFeatureLayer.FeatureClass.Search(pQueryFilter,true);//IFeatureClasspFeatureCls=pFeatureLayer.FeatureClass.Search(pQueryFilter,true);//再定义一个要素集合,这样才能编辑,搞这么麻烦。。我也不知道为什么pFields=pFeatureCursor.Fields;dgv.ColumnCount=pFields.FieldCount;for(inti=0;i<pFields.FieldCount;i++)stringfldName=pFields.get_Field(i).Name;dgv.Columns[i].Name=fldName;dgv.Columns[i].ValueType=System.Type.GetType(ParseFieldType(pFields.get_Field(i).Type));longlTotalRecords=0;IFeaturepFeature=pFeatureCursor.NextFeature();while(pFeature!=null)string[]fldValue=newstring[pFields.FieldCount];for(inti=0;i<pFields.FieldCount;i++)stringfldName;fldName=pFields.get_Field(i).Name;if(fldName==pFeatureLayer.FeatureClass.ShapeFieldName)fldValue[i]=Convert.ToString(pFeature.Shape.GeometryType);elsefldValue[i]=Convert.ToString(pFeature.get_Value(i));dgv.Rows.Add(fldValue);pFeature=pFeatureCursor.NextFeature();lTotalRecords++;//内存回收System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFeatureCursor);pFeatureCursor=null;pStatusLabel1.Text="共有"+Convert.ToString(lTotalRecords)+"条记录";
/
本文档为【C#-AE-ArcGlobe-图层上画点、画线、图层矢量数据查询】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索