Chinaunix首页 | 论坛 | 博客
  • 博客访问: 717957
  • 博文数量: 33
  • 博客积分: 10012
  • 博客等级: 上将
  • 技术积分: 1365
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-15 09:11
文章分类
文章存档

2009年(10)

2008年(23)

我的朋友

分类:

2009-03-26 17:05:22

老师需要一个和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();
            }
        }
阅读(3153) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~