本文主要是介绍ArcGIS Engine实现点选要素,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
大致分为三步
- 获得点击位置的坐标
- 根据坐标生成缓冲区
- 查询与缓冲区相交的要素
在AxMapControl的点击事件获得点击位置并转换为坐标
IPoint point = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(MousePosition.X, MousePosition.Y);
获得查询的目标图层
ILayer pLayer = axMapControl1.get_Layer(5);
执行查询操作
List<IFeature> pFeaturesList = getPointSelect(point, pLayer as IFeatureLayer, 2);
根据点击位置进行查询的函数
private List<IFeature> getPointSelect(IPoint pPoint,IFeatureLayer pFeatureLayer,double pRadius){List<IFeature> pSelectedFeatureList = new List<IFeature>(); //返回要素类ITopologicalOperator pTop = pPoint as ITopologicalOperator;IGeometry pGeometry = pTop.Buffer(pRadius); //建立缓冲区ISpatialFilter pSpatialFilter = new SpatialFilterClass(); //空间查询模块pSpatialFilter.Geometry = pGeometry; //查询内容pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; //求交IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(pSpatialFilter, false);IFeature pFeature = pFeatureCursor.NextFeature();while (pFeature != null){pSelectedFeatureList.Add(pFeature);pFeature = pFeatureCursor.NextFeature();}return pSelectedFeatureList;}
这篇关于ArcGIS Engine实现点选要素的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!