zoukankan      html  css  js  c++  java
  • 图层的自动标注

            /// <summary>
            /// 自动标注图层
            /// </summary>
            /// <param name="pGeoFlyr">矢量图层对象</param>
            /// <param name="pAutoLbl">动态标注对象</param>
            public void SetLayerAutoLabel(IGeoFeatureLayer pGeoFlyr)
            {
                try
                {
                    if (pGeoFlyr == null)
                        return;
                    IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFlyr.AnnotationProperties;

                    pAnnoProps.Clear();

                    IAnnotateLayerProperties pAnnoLayerProps;
                    ILineLabelPosition pPosition;
                    ILineLabelPlacementPriorities pPlacement;
                    IBasicOverposterLayerProperties pBasic;
                    ILabelEngineLayerProperties pLabelEngine;

                    ITextSymbol pTextSymbol = new TextSymbolClass();
                    IRgbColor pColor = new RgbColorClass() { Red = 250, Blue = 0, Green = 0 };
                    stdole.StdFont pFont = new StdFontClass();
                    pFont.Name = "文鼎CS细等线";
                    pFont.Size = 50;
                    pTextSymbol.Font = pFont as stdole.IFontDisp;
                    pTextSymbol.Color = pColor;

                    pPosition = new LineLabelPositionClass();
                    pPosition.Parallel  = true   ;
                    pPosition.InLine = false ;
                    pPosition.Perpendicular = false ;
                    pPosition.Above = true;
                    pPlacement = new LineLabelPlacementPrioritiesClass();
                    pPlacement.AboveStart = 5;
                    pPlacement.BelowAfter = 4;
                    pBasic = new BasicOverposterLayerPropertiesClass();
                    pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                    pBasic.LineLabelPlacementPriorities = pPlacement;
                    pBasic.LineLabelPosition = pPosition;
                    pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;

                    pLabelEngine = new LabelEngineLayerPropertiesClass();
                    pLabelEngine.Symbol = pTextSymbol;
                    pLabelEngine.BasicOverposterLayerProperties = pBasic;
                    string annoField = "[Shape_Length]";
                    pLabelEngine.Expression = annoField;
                    pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
                    pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriSelectedFeatures;
                    pAnnoLayerProps.WhereClause = "Shape_Length>40";
                    pAnnoProps.Add(pAnnoLayerProps);
                    pGeoFlyr.AnnotationProperties = pAnnoProps;
                    pGeoFlyr.DisplayAnnotation = true;

                }
                catch (Exception Err)
                {
                    MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
    注意红色部分字段格式以及条件的书写方式

  • 相关阅读:
    连通域搜索
    识别深色浅色
    新年,博客搬家了!!!
    C++11 —— 使用 thread 实现线程池
    自己实现的网络字节序转换函数
    GUI 编程 —— QT 的 QSlider 鼠标点击定位问题
    单生产者/单消费者 的 FIFO 无锁队列
    用模板类特化的方式实现工厂模式
    C++11 —— 简易的旋转锁类
    C++11 —— 获取 tuple 参数列表中指定数据类型的索引位置
  • 原文地址:https://www.cnblogs.com/sdustyuleyi/p/2652470.html
Copyright © 2011-2022 走看看