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

  • 相关阅读:
    数组里的数据绑定到dataset中
    有关字符串匹配的方法
    sql语句全集
    Dialog 的6中提示方式
    android开源项目和框架
    MyEclipse DB Browser使用图文全攻略
    省市县联动(转)
    LRU算法
    Java 性能优化小细节
    HashMap
  • 原文地址:https://www.cnblogs.com/cannel/p/2480507.html
Copyright © 2011-2022 走看看