在ArcGIS10中AO编辑操作

来源:互联网 发布:移动网络波动怎么解决 编辑:程序博客网 时间:2024/05/21 04:38

ArcGIS10AO进行编辑出现了颠覆性的改变,一改以前版本的编辑工具、编辑任务,而是通过模版和图层关联进行编辑操作。其中涉及到IEditTemplate,正是由这个IEditTemplate的接口来实现地图的编辑操作,那么如何进行编辑操作呢?首先需要取到IEditor3接口的实例和IEditTemplate接口的实例。下面代码将展示如何获得这两个接口的实例

privateIApplication m_application;
private IEditor3 m_editor;

m_application =ArcMap.Application;

UID editorUid =new UID();
editorUid.Value = “esriEditor.Editor”;
m_editor = m_application.FindExtensionByCLSID(editorUid) as IEditor3;
m_editTemplate = m_editor.CurrentTemplate;

if(m_editTemplate == null)
{
        //Create a single template forthe selected layer.
         ILayer editLayer =m_document.SelectedLayer;
         IEditTemplateFactoryeditTemplateFact = new EditTemplateFactoryClass();
         IEditTemplatenewEditTemplate = editTemplateFact.Create(“Building”, m_featurelayer);
          m_editTemplate =newEditTemplate;
           //Add thetemplate.
           IArraytemplateArray = new ArrayClass();
           templateArray.Add(m_editTemplate);
            m_editor.AddTemplates(templateArray);
            m_editor.CurrentTemplate= m_editTemplate;
 }

此时编辑模版将被获得并且与FeatureLayer相关联就可以进行编辑操作了,添加点要素,然后对新添加的点要素进行高亮显示

IPoint pt = new PointClass();
pt.X = 123.3456;
pt.Y = 41.3456;
IFeature m_feature = m_featureclass.CreateFeature();
m_feature.Shape = pt;
m_editTemplate.SetDefaultValues(m_feature);
m_feature.Store();
m_document.FocusMap.SelectFeature(m_featurelayer, m_feature);
m_document.ActiveView.Refresh();

从以上代码中我们可以看出,这种操作与ArcGIS9中的AO操作截然不同,是两种模式。

0 0