zoukankan      html  css  js  c++  java
  • ArcGIS Engine获取单条要素的标注(LABEL)内容

    众所周知,arcgis的标注设置是对整个图层的,那有没有办法获取某条要素的标注内容呢?当然有!!!

    分两步,第一步先获取layer级别的IAnnotationExpressionParser对象,获取标注内容靠他了

     1             IAnnotationExpressionParser tAnnoExpParse = null;
     2 
     3             IAnnotateLayerPropertiesCollection tAnnotateLayerPropertiesCollection = tGeoFeatureLayer.AnnotationProperties;
     4             IAnnotateLayerProperties tAnnotateLayerProperties = null;
     5             IElementCollection tElementCollection = null;     
     6             if (tAnnotateLayerPropertiesCollection.Count > 0)
     7             {
     8                 tAnnotateLayerPropertiesCollection.QueryItem(0, out tAnnotateLayerProperties, out tElementCollection, out tElementCollection);
     9                 ILabelEngineLayerProperties tLabelEngineLayerProperties = tAnnotateLayerProperties as ILabelEngineLayerProperties;     
    10                 //获取标注解析类
    11                 IAnnotationExpressionEngine tAnnoExpEngine = tLabelEngineLayerProperties.ExpressionParser;
    12                 if (tLabelEngineLayerProperties.IsExpressionSimple == true)
    13                 {
    14                     tAnnoExpParse = tAnnoExpEngine.SetExpression("", tLabelEngineLayerProperties.Expression);
    15                 }
    16                 else
    17                 {
    18                     tAnnoExpParse = tAnnoExpEngine.SetCode(tLabelEngineLayerProperties.Expression, "");
    19                 }

    第二步相对简单,关键函数是FindLabel

    string labelValue = tAnnoExpParse.FindLabel(tFeature);

    关于这种方法还有点疑问

    首先,获取用SetExpression和SetCode这两个函数去获取IAnnotationExpressionParser感觉很怪,非得要赋值才能取值很有问题。

    其次SetExpression和SetCode这两个函数有些参数不理解,所以只是给了空值,这也是个隐患

  • 相关阅读:
    grub损坏修复方法
    基本命令(一)
    python 及 ipython 源码安装
    Samba服务安装配置
    shell语法一
    cacti监控软件
    Telnet服务安装及配置
    LVM逻辑卷,RAID磁盘阵列
    运维笔试题4(转载)
    运维笔试题3(转载)
  • 原文地址:https://www.cnblogs.com/cannel/p/2480507.html
Copyright © 2011-2022 走看看