zoukankan      html  css  js  c++  java
  • ArcGIS Engine中如何获取Map中已经选择的要素呢

    1、使用IEnumFeturea对象获取map中的FeatureSelection,该方法可以获取所有图层的选择要素。IMap中的FeatureSelection可不是IFeatureSelection,而是ISelection

     

    2、使用ISelectionSetIEnumIDsFeatureClass.GetFeature()方法获取某个图层中的选择要素

     

    在map中获取要素时,这样是可以的,不过不能得到要素的完整属性信息,貌似只能拿到ID值。

    ISelection pSelection = pMap.FeatureSelection;

               IEnumFeature enumFeature = pSelection asIEnumFeature;

               IFeature feature = enumFeature.Next();

                while (feature != null)

                {

                   array.Add(feature);

                   feature=enumFeature.Next();

                }

    那如果要得到完整的属性信息怎么办呢?IEnumFeatureSetup起到大作用了。如下所示:

    ISelection selection = pMap.FeatureSelection;

    IEnumFeatureSetup enumFeatureSetup = selection as IEnumFeatureSetup;    //这里很必要

    enumFeatureSetup.AllFields = true;                                      //这里很必要

    IEnumFeature enumFeature = enumFeatureSetup as IEnumFeature;

    enumFeature.Reset(); 

    IFeature feature = enumFeature.Next();

    while (feature != null)

          {

            stringvalue = feature.get_Value(index).ToString();//就可以得到任意字段的值了 

            feature = enumFeature.Next();

           }

     

  • 相关阅读:
    SpringBoot自定义过滤器的两种方式及过滤器执行顺序
    如何用上新版本的 IDEA(IDEA 2019.2.2版本)
    IDEA乱码Tomcat控制台乱码输出乱码报文乱码
    单例模式的几种实现方式及对比
    Java中synchronized关键字你知道多少
    [转载]Vertica “ERROR: Too many ROS containers exist”
    FTP Client
    统计数据库表大小
    常用JS代码整理
    WinForm 控件不闪烁
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3294035.html
Copyright © 2011-2022 走看看