• 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这两个函数有些参数不理解,所以只是给了空值,这也是个隐患

  • 相关阅读:
    lambda表达式
    You can't specify target table 't_mail_marketing' for update in FROM clause
    从对象list中获取对象属性list
    枚举缓存
    Solr语法
    通过Telnet查询注册服务
    日志查询
    Maven 屏蔽静态文件
    抽奖
    随机码生成方法
  • 原文地址:https://www.cnblogs.com/cannel/p/2480507.html
Copyright © 2020-2023  润新知