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提取出来。

  • 相关阅读:
    git命令上传项目到码云总结
    根据数组对象的某个属性值找到指定的元素
    Web前端开发规范文档
    在vue项目中安装使用Mint-UI
    字蛛fontSpider的使用
    vue 组件之间的数据传递
    ElasticStack系列之十 & 生产中的问题与解决方案
    ElasticStack系列之九 & master、data 和 client 节点
    ElasticStack系列之八 & _source 字段
    ElasticStack系列之七 & IK自动热更新原理与实现
  • 原文地址:https://www.cnblogs.com/arxive/p/6262979.html
Copyright © 2011-2022 走看看