老师需要一个和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();
}
}
阅读(3206) | 评论(0) | 转发(0) |