• arcgis engine空间查询与属性查询的主要代码 (转)


    转自:http://blog.csdn.net/qinyilang/article/details/6321079


    属性查询是在当前map的layer中获取符合条件的feature的集合,实现过程是获取featurelayer的featureclass。然后定义过滤条件。在featureclass中执行search函数。获取查询结果。主要代码:

    ILayer layer = axMapControl1.get_Layer(0);
    IFeatureLayer featureLayer = layer as IFeatureLayer;
    //获取featureLayer的featureClass
    IFeatureClass featureClass = featureLayer.FeatureClass;
    IFeature feature = null;

    IQueryFilter queryFilter = new QueryFilterClass();

    IFeatureCursor featureCusor;
    queryFilter.WhereClause = "name = '" + searchName + "'";
    featureCusor = featureClass.Search(queryFilter, true);

    //search的参数第一个为过滤条件,第二个为是否重复执行。

    feature = featureCusor.NextFeature();

    if (feature != null)
    {
    axMapControl1.Map.SelectFeature(axMapControl1.get_Layer(0), feature);
    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
    }

    空间查询实现起来比较简单,使用arcgis封装好的函数即可,主要是获取选取的geometry对象:

    axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair;
    IGeometry geometry = null;
    switch (actionFlag)
    {
    case flag.POINTSELECT://点选
    ESRI.ArcGIS.Geometry.Point pt = new ESRI.ArcGIS.Geometry.Point();
    pt.X = e.mapX;
    pt.Y = e.mapY;
    geometry = pt as IGeometry;
    break;
    case flag.CIRCLESELECT://圆选
    geometry = axMapControl1.TrackCircle();
    break;
    case flag.RECTSELECT://长方形选取
    geometry = axMapControl1.TrackRectangle();
    break;
    case flag.POLYGONSELECT://多边形选取
    geometry = axMapControl1.TrackPolygon();
    break;
    }
    axMapControl1.Map.SelectByShape(geometry, null, false);
    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);


    from:http://blog.csdn.net/zzjiadw/article/details/7669382
  • 相关阅读:
    性能测试 概述
    Jmeter 逻辑控制器 仅一次控制器Once Only Controller 一次登录,多次查询
    npm run build的时候报错:FATAL ERROR: Ineffective markcompacts near heap limit Allocation failed
    RAC修改私有网络IP(19C)
    如何关闭tfa
    创建asm磁盘指定failgroup
    删除冗余磁盘测试
    es磁盘满了无法写入的处理办法
    双系统启动问题
    openvmtools
  • 原文地址:https://www.cnblogs.com/yuxuetaoxp/p/2751037.html
Copyright © 2020-2023  润新知