convert labels to geodatabase annotation

16 篇文章 0 订阅
老师需要一个和ARCGIS里Convert Label To Annotate FeatureClass的功能。主要方便大数据量的图形转换。查了几天,毫无头绪,自己都忘记了在 AE开发帮助里进行搜索。到头来,得来不费功夫,还耗费我那么长时间。
当然,这些时间也让自己对Annotate这个东西有了更深的认识。
有IAnnotateLayer却好像没有IAnnotateFeatureclass这个东西。
最后在Arcgis中还有一个ConvertLabelsToAnnotationClass的类,真是气煞我也阿。
下面是一段将Labels转换位AnnotateLayer的代码
只是现在还不是很清楚Labels的具体含义和用法
private void ConvertLabelsToGDBAnnotationSingleLayer(IMap pMap, ILayer pLayer, bool featureLinked)
        {

            IConvertLabelsToAnnotation pConvertLabelsToAnnotation = new ConvertLabelsToAnnotationClass();
            ESRI.ArcGIS.esriSystem.ITrackCancel pTrackCancel = new CancelTrackerClass();
            //Change global level options for the conversion by sending in different parameters to the next line.
            pConvertLabelsToAnnotation.Initialize(pMap, esriAnnotationStorageType.esriDatabaseAnnotation,
                                                      esriLabelWhichFeatures.esriAllFeatures, true, pTrackCancel, null);

         
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;
            if (pGeoFeatureLayer != null)
            {
                IFeatureClass pFeatureClass = pGeoFeatureLayer.FeatureClass;
                IDataset pDataset = pFeatureClass as IDataset;

                IFeatureWorkspace pFeatureWorkspace = pDataset.Workspace as IFeatureWorkspace;
                //Add the layer information to the converter object. Specify the parameters of the output annotation feature class here as well.
                try
                {
                    pConvertLabelsToAnnotation.AddFeatureLayer(pGeoFeatureLayer, pGeoFeatureLayer.Name + "_Anno",
                                                                  pFeatureWorkspace, pFeatureClass.FeatureDataset,
                                                                  featureLinked, false, false, true, true, "");
                }
                catch(Exception s)
                {
                    System.Windows.Forms.MessageBox.Show(s.Message);
                }
                //Do the conversion.
                pConvertLabelsToAnnotation.ConvertLabels();
                IEnumLayer pEnumLayer = pConvertLabelsToAnnotation.AnnoLayers;
                //Turn off labeling for the layer converted.
                pGeoFeatureLayer.DisplayAnnotation = false;

                //Add the result annotation layer to the map.
                pMap.AddLayers(pEnumLayer, true);

                //Refresh the map to update the display.
                IActiveView pActiveView = pMap as IActiveView;
                pActiveView.Refresh();
            }
        }


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值