Ejemplo n.º 1
0
 /// <summary>
 /// 赋予属性
 /// </summary>
 /// <param name="recordNode">属性信息</param>
 public void AttachAttribute(RecordNode recordNode, TableStructureNode pTableStructNode)
 {
     try
     {
         if (m_pIFeature != null)
         {
             if (m_pIFeature is IAnnotationFeature)
             { 
                 ///添加注记数据
             }
             else
             {
                 for (int i = 0; i < pTableStructNode.FieldNodes.Count; i++)
                 {
                     FieldNode pFieldNode = pTableStructNode.FieldNodes[i];
                     string sValue = recordNode.FieldValues[i];
                     m_pIFeature.set_Value(pFieldNode.FieldIndex, sValue);
                 }
                 m_pIFeature.Store();
             }
         }
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Ejemplo n.º 2
0
		/// <summary>
		/// 创建空间图层
		/// </summary>
		/// <param name="tableStructureNode">VCT表结构节点</param>
		/// <param name="featureCodeNode">VCT要素编码节点</param>
		private FeatureLayer CreateFeatureLayer(TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                FeatureLayer featureLayer = null;
                ///获取要素集
                IFeatureDataset featureDataset = m_pIDataset as IFeatureDataset;


                //从配置文件读取图形类型
                string sGeometryType = "";
                Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                if (pMetaTalbe != null)
                {
                    sGeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark(pMetaTalbe.Type);
                }
                else
                {
                    Logger.WriteLog("未能获取【" + tableStructureNode.TableName + "】的图形类型!");
                    return null;
                }
                ///创建点实体
                if (sGeometryType == "Point")
                {
                    featureLayer = new PointLayer();
                   
                }
                 ///创建线实体
                else if (sGeometryType == "Line")
                {
                    featureLayer = new LineLayer();
                  
                }
                ///创建面实体
                else if (sGeometryType == "Polygon")
                {
                    featureLayer = new PolygonLayer();
                }
                else if (sGeometryType == "Annotation")
                {
                    featureLayer = new AnnotationLayer();
                }

                if (featureLayer != null)
                {
                    featureLayer.StructureNode = tableStructureNode;

                    IFeatureClass pFcls = CreateFeatureClass(featureDataset, tableStructureNode, featureCodeNode);
                    featureLayer.Table = pFcls as ITable;
                    featureLayer.UpdateFieldIndex();
                    return featureLayer;
                }
            }
            catch(Exception ex)
            {
                Logger.WriteErrorLog(ex);
            }
            return null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建属性表
        /// </summary>
        /// <param name="pFeatureWorkspace"></param>
        /// <param name="tableStructureNode"></param>
        /// <param name="featureCodeNode"></param>
        /// <returns></returns>
        private TableLayer CreateTableLayer(IFeatureWorkspace pFeatureWorkspace, TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                if (pFeatureWorkspace != null&&tableStructureNode!=null&&featureCodeNode!=null)
                {
                    IObjectClassDescription ocDescription = new ObjectClassDescriptionClass();
                    ///创建数据表字段
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///字段信息验证
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = pFeatureWorkspace as IWorkspace;
                    IEnumFieldError enumFieldError = null;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ITable pTable = pFeatureWorkspace.CreateTable(tableStructureNode.TableName, fixFields,
                        ocDescription.InstanceCLSID, null, "");
                    if (pTable != null)
                    {
                        TableLayer pTableLayer = new TableLayer();

                        //从配置文件读取图形类型
                        string sGeometryType = "";
                        Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                        if (pMetaTalbe != null)
                        {
                            sGeometryType = pMetaTalbe.Type;
                        }
                        else
                            return null;

                        pTableLayer.GeometryType = sGeometryType;
                        pTableLayer.Table = pTable;
                        pTableLayer.UpdateFieldIndex();
                        return pTableLayer;
                    }
                    return null;
                }
                return null;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取VCT表结构节点
        /// </summary>
        private TableStructureNode GetTableStructureNode()
        {
            try
            {
                m_TableStructureNode = new TableStructureNode();
                ///判断当前是否为空间数据表
                if (m_pITable is IFeatureClass)
                {
                    m_TableStructureNode.IsGeometryTable = true;
                    IFeatureClass pFeatureCls = this.m_pITable as IFeatureClass;
                    ///获取表名称
                    m_TableStructureNode.TableName = (m_pITable as IDataset).Name;
                }
                else
                {
                    m_TableStructureNode.IsGeometryTable = false;
                    //m_TableStructureNode.TableName = (m_pITable as IObjectClass).AliasName;
                    m_TableStructureNode.TableName = (m_pITable as IDataset).Name;
                }
                //获取字段信息
                m_TableStructureNode.FieldNodes = GetFieldNodes(m_pITable.Fields);

                ///通过配置获取标识码字段名称
                string sKeyFieldName = "";
                sKeyFieldName = Metadata.MetaDataFile.GetEntityIDFieldName(m_TableStructureNode.TableName);
                if (sKeyFieldName != "")
                {
                    m_strEntityFieldName = sKeyFieldName;
                }

                ///通过配置获取要素代码字段名称
                sKeyFieldName = Metadata.MetaDataFile.GetYSDMFieldName(m_TableStructureNode.TableName);
                if (sKeyFieldName != "")
                {
                    m_strEntityFieldName = sKeyFieldName;
                }
                return(m_TableStructureNode);
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return(null);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取VCT属性记录节点
        /// </summary>
        public RecordNode GetRecordNode(TableStructureNode pTableStructNode)
        {
            try
            {
                RecordNode pRecordNode = new RecordNode();
                /////标识码赋值
                //int dBSMIndex = -1;
                //dBSMIndex = this.Feature.Fields.FindField("BSM");
                //if (dBSMIndex != -1)
                //    pRecordNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex));
                List<string> sListValues = new List<string>();
              
                for (int i = 0; i < pTableStructNode.FieldNodes.Count; i++)
                {
                    //IField pField = this.Feature.Fields.get_Field(i);
                    //string sValue = this.Feature.get_Value(i).ToString();
                    /////只保存属性数据
                    //if (pField.Type != esriFieldType.esriFieldTypeOID
                    //    && pField.Type != esriFieldType.esriFieldTypeGeometry
                    //    && pField.Name.ToUpper() != "SHAPE_LENGTH"
                    //    && pField.Name.ToUpper() != "SHAPE_AREA")
                    //{]
                    
                    FieldNode pFieldNode = pTableStructNode.FieldNodes[i];
                    if (pFieldNode.FieldName == m_strEntityIDFiled)
                    {
                        sListValues.Insert(0, this.Feature.get_Value(pFieldNode.FieldIndex).ToString());
                        pRecordNode.EntityID =Convert.ToInt32( this.Feature.get_Value(pFieldNode.FieldIndex));
                    }
                    else
                    sListValues.Add(this.Feature.get_Value(pFieldNode.FieldIndex).ToString());
                    //}
                }
                pRecordNode.FieldValues = sListValues;
                return pRecordNode;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }

        }
Ejemplo n.º 6
0
        /// <summary>
        /// 创建
        /// </summary>
        public virtual bool Create(TableStructureNode tableStructureNode)
        {
            m_TableStructureNode = tableStructureNode;

            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 创建
        /// </summary>
        public override bool Create(TableStructureNode tableStructureNode)
        {
            base.Create(tableStructureNode);

            return true;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 创建字段集合
        /// </summary>
        /// <param name="ocDescription">要素类描述</param>
        /// <param name="tableStructureNode">表结构节点</param>
        /// <returns></returns>
        private IFields CreateFileds(TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                ///创建字段集合
                IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass();
                IObjectClassDescription ocDescription = new ObjectClassDescriptionClass();
                IFields fields = ocDescription.RequiredFields;

                //从配置文件读取图形类型
                string sGeometryType = "";
                Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                if (pMetaTalbe != null)
                {
                    sGeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark(pMetaTalbe.Type);
                }

                //设置图形类型
                if (sGeometryType != "NoneGeometry")
                {
                    ocDescription = (IObjectClassDescription)fcDescription;
                    fields = ocDescription.RequiredFields;
                    int shapeFieldIndex = fields.FindField(fcDescription.ShapeFieldName);
                    IField pGeometryfield = fields.get_Field(shapeFieldIndex);
                    IGeometryDef geometryDef = pGeometryfield.GeometryDef;
                    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                    if (sGeometryType == "Point")
                        geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                    else if (sGeometryType == "Line")
                        geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
                    else if (sGeometryType == "Polygon")
                        geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;

                }
                IFieldsEdit fieldsEdit = fields as IFieldsEdit;
                // 遍历表结构数据
                int FieldCount = tableStructureNode.FieldNodes.Count;
                for (int i = 0; i < FieldCount; i++)
                {
                    IField field = new FieldClass();
                    IFieldEdit fieldEdit = (IFieldEdit)field;
                    ///获取字段信息
                    FieldNode pFieldNode = tableStructureNode.FieldNodes[i];
                    if (pFieldNode != null)
                    {
                        ///设置字段值
                        fieldEdit.Name_2 = pFieldNode.FieldName;

                        //从配置中获取别名
                        if (pMetaTalbe != null)
                            fieldEdit.AliasName_2 = pMetaTalbe.GetFiledALisNameByCode(pFieldNode.FieldName);
                        esriFieldType type = esriFieldType.esriFieldTypeString;
                        switch (pFieldNode.FieldType)
                        {
                            case "Char":
                                type = esriFieldType.esriFieldTypeString;         
                                break;
                            case "Int":
                                type = esriFieldType.esriFieldTypeInteger;
                                break;
                            case "Float":
                                type = esriFieldType.esriFieldTypeDouble;
                                break;
                            case "Time":
                                type = esriFieldType.esriFieldTypeDate;
                                break;
                            case "DateTime":
                                type = esriFieldType.esriFieldTypeDate;
                                break;
                            case "Varchar":
                                type = esriFieldType.esriFieldTypeString;
                                break;
                            case "Varbin":
                                type = esriFieldType.esriFieldTypeString;
                                break;
                            default:
                                break;
                        }
                        fieldEdit.Type_2 = type;
                        fieldEdit.Length_2 = pFieldNode.FieldLength;
                        fieldEdit.Precision_2 = pFieldNode.FieldPrecision;
                        fieldsEdit.AddField(field);
                    }
                }
                return fields;
            }
            catch(Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }

        }
Ejemplo n.º 9
0
        private IFeatureClass CreateFeatureClass(IFeatureDataset featureDataset,TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode) 
        {
            try
            {
                if (featureDataset != null)
                {
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;
         
                    ///创建数据表字段
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IEnumFieldError enumFieldError = null;
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///字段信息验证
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = featureDataset.Workspace;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ////创建FeatureClass
                    IFeatureClass featureClass = null;
                    if (tableStructureNode.IsGeometryTable)
                    {
                        ////创建非注记FeatureClass
                        if (featureCodeNode.GeometryType != "")
                        {
                            featureClass = featureDataset.CreateFeatureClass(featureCodeNode.TableName,
                               fixFields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID,
                               esriFeatureType.esriFTSimple, fcDesc.ShapeFieldName, "");
                        }
                        else
                        {
                            ///创建注记
                            IFormattedTextSymbol pTxtSymbo=new TextSymbolClass();

                            IFeatureWorkspaceAnno pFeatureWorkspaceAnno = this.m_pIDataset.Workspace as IFeatureWorkspaceAnno;

                            IGraphicsLayerScale pGraphSacle = new GraphicsLayerScaleClass();
                            pGraphSacle.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            //pGraphSacle.ReferenceScale=1000;


                            ISymbolCollection pSymbolCollection = new SymbolCollectionClass();

                            IAnnotateLayerProperties pAnnoLayerProp = new LabelEngineLayerPropertiesClass();
                            pAnnoLayerProp.FeatureLinked = true;
                            pAnnoLayerProp.CreateUnplacedElements = false;
                            pAnnoLayerProp.DisplayAnnotation = true;
                            pAnnoLayerProp.UseOutput = true;

                            IAnnotationExpressionEngine pAnnoExpressionEngine =new AnnotationVBScriptEngineClass();
                            ILabelEngineLayerProperties pLabelEngineLayerProperties = pAnnoLayerProp as ILabelEngineLayerProperties;
                            pLabelEngineLayerProperties.ExpressionParser = pAnnoExpressionEngine;
                            pLabelEngineLayerProperties.Expression = "[DESCRIPTION]";
                            pLabelEngineLayerProperties.IsExpressionSimple = true;
                            pLabelEngineLayerProperties.Offset = 0;
                            pLabelEngineLayerProperties.SymbolID = 0;
                            pLabelEngineLayerProperties.Symbol = pTxtSymbo;

                            IAnnotateLayerTransformationProperties pAnnoLayerTransProp = pAnnoLayerProp as IAnnotateLayerTransformationProperties;
                            pAnnoLayerTransProp.ReferenceScale=200;
                            pAnnoLayerTransProp.Units= ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            pAnnoLayerTransProp.ScaleRatio=1;

                            IAnnotateLayerPropertiesCollection pAnnoLayerProptyCollection =new AnnotateLayerPropertiesCollectionClass();
                           pAnnoLayerProptyCollection.Add(pAnnoLayerProp);

                           featureClass= pFeatureWorkspaceAnno.CreateAnnotationClass(featureCodeNode.TableName,fixFields,ocDesc.InstanceCLSID
                               ,ocDesc.ClassExtensionCLSID,fcDesc.ShapeFieldName,"",featureDataset,null,
                               pAnnoLayerProptyCollection, pGraphSacle, pSymbolCollection,true);
                        }
                    }
                    else
                    {
                        ///创建非空间数据
                    }
                    return featureClass;
                }
                return null;
            }
            catch(Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
        }