zoukankan      html  css  js  c++  java
  • 要素类的复制方法

    转自原文 要素类的复制方法

    如何根据一个要素类(源要素类)在另一个工作空间中产生一个同字段,但空间范围可能不一致的要素类(目标要素类)?本文提供了完备的方法。

     public ESRI.ArcGIS.Geodatabase.IFeatureClass CloneFeatureClass(ESRI.ArcGIS.Geodatabase.IFeatureClass srcFeatureClass, ESRI.ArcGIS.Geodatabase.IFeatureWorkspace SaveFeatWorkspace, string Name, ESRI.ArcGIS.Geometry.IEnvelope newEnvelope)
    {
        if (Name == ""||Name ==null)
        {
            Name = srcFeatureClass.AliasName;
        }
        Name = this.getRightDatasetName(Name, ".");
    
        IFields pFields = this.CloneFeatureClassFields(srcFeatureClass, newEnvelope);
        //Anno要素类
        if (srcFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
        {
            //Anno Workspace
            IFeatureWorkspaceAnno pFWSAnno =SaveFeatWorkspace as IFeatureWorkspaceAnno;
            //获得AnnoFeatureClass的显示参数units和referencescale
            IAnnoClass pAnnoClass = srcFeatureClass.Extension as IAnnoClass;
    
            IGraphicsLayerScale pGLS = new GraphicsLayerScaleClass();
            pGLS.Units = pAnnoClass.ReferenceScaleUnits;
            pGLS.ReferenceScale = pAnnoClass.ReferenceScale;
    
            ISymbol pSymbol = (ISymbol)MakeTextSymbol();
            //Anno要素类必须有的缺省符号
            ISymbolCollection2 pSymbolColl = new SymbolCollectionClass();
            ISymbolIdentifier2 pSymID = new SymbolIdentifierClass();
            pSymbolColl.AddSymbol(pSymbol, "Default", out pSymID);
    
            //Anno要素类的必要属性
            IAnnotateLayerProperties pAnnoProps = new LabelEngineLayerPropertiesClass();
            pAnnoProps.CreateUnplacedElements = true;
            pAnnoProps.CreateUnplacedElements = true;
            pAnnoProps.DisplayAnnotation = true;
            pAnnoProps.UseOutput = true;
    
            ILabelEngineLayerProperties pLELayerProps = (ILabelEngineLayerProperties)pAnnoProps;
            pLELayerProps.Symbol = pSymbol as ITextSymbol;
            pLELayerProps.SymbolID = 0;
            pLELayerProps.IsExpressionSimple = true;
            pLELayerProps.Offset = 0;
            pLELayerProps.SymbolID = 0;
    
            IAnnotationExpressionEngine aAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();
            pLELayerProps.ExpressionParser = aAnnoVBScriptEngine;
            pLELayerProps.Expression = "[DESCRIPTION]";
            IAnnotateLayerTransformationProperties pATP = (IAnnotateLayerTransformationProperties)pAnnoProps;
            pATP.ReferenceScale = pGLS.ReferenceScale;
            pATP.ScaleRatio = 1;
    
            IAnnotateLayerPropertiesCollection pAnnoPropsColl = new AnnotateLayerPropertiesCollectionClass();
            pAnnoPropsColl.Add(pAnnoProps);
    
            IObjectClassDescription pOCDesc = new AnnotationFeatureClassDescription();
    
            return pFWSAnno.CreateAnnotationClass(Name, pFields, pOCDesc.InstanceCLSID, pOCDesc.ClassExtensionCLSID, srcFeatureClass.ShapeFieldName, "", null, null, pAnnoPropsColl, pGLS, pSymbolColl, true);
        }
        else
        {
            return SaveFeatWorkspace.CreateFeatureClass(Name, pFields, null, null, esriFeatureType.esriFTSimple, srcFeatureClass.ShapeFieldName, "");
        }
    }

    方法中的两个函数,一个getRightDatasetName是解析要素类名称,即能够将诸如SDE.FC转换为FC。另一个方法CloneFeatureClassFields则是将一个要素类的Fields提取出来。

  • 相关阅读:
    转 UICollectionView 详解
    springboot配置ssl证书
    服务器ganglia安装(带有登录验证)
    eureka配置说明
    Servlet中获取请求参数问题
    apidoc学习(接口文档定义取代word)
    markdown语法
    JVM分析
    ftp上传或下载文件工具类
    ubuntu命令安装
  • 原文地址:https://www.cnblogs.com/arxive/p/6262979.html
Copyright © 2011-2022 走看看