ArcGIS Engine实现点选要素

本文介绍了一种基于ArcGIS的点击查询技术实现方案,通过获取点击位置坐标、生成缓冲区并查询与之相交的地理要素,实现地图上目标要素的快速定位与筛选。

大致分为三步

  • 获得点击位置的坐标
  • 根据坐标生成缓冲区
  • 查询与缓冲区相交的要素

在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;
        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值