Exemple #1
0
        /// <summary>
        /// 获取要素代码节点
        /// </summary>
        /// <returns></returns>
        public virtual FeatureCodeNode GetFeatureCodeNode()
        {
            try
            {
                FeatureCodeNode pFeatureCodeNode = new FeatureCodeNode();
                ///如果是空间数据
                if (m_pITable is IFeatureClass)
                {
                    ///要素名称
                    pFeatureCodeNode.FeatureName = (m_pITable as IObjectClass).AliasName;

                    //要素代码
                    string sAttriTableName = (m_pITable as IDataset).Name;
                    pFeatureCodeNode.FeatureCode = MetaDataFile.GetFeatureCodeByName(sAttriTableName);

                    ///获取要素类型
                    if ((m_pITable as IFeatureClass).FeatureType != esriFeatureType.esriFTAnnotation)
                    {
                        switch ((m_pITable as IFeatureClass).ShapeType)
                        {
                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine:
                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Line");
                            break;

                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Point");
                            break;

                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Polygon");
                            break;

                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryNull:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("NoneGeometry");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Annotation");
                    }
                    ///数据表名称
                    pFeatureCodeNode.TableName = sAttriTableName;

                    ///获取标识码字段
                    string sKeyFieldName = "";
                    sKeyFieldName = Metadata.MetaDataFile.GetEntityIDFieldName(sAttriTableName);
                    if (sKeyFieldName != "")
                    {
                        m_strEntityFieldName = sKeyFieldName;
                    }

                    ////获取要素代码字段
                    sKeyFieldName = Metadata.MetaDataFile.GetYSDMFieldName(sAttriTableName);
                    if (sKeyFieldName != "")
                    {
                        m_strSYDMFieldName = sKeyFieldName;
                    }
                }
                ///如果是属性数据
                else if (m_pITable != null)
                {
                    pFeatureCodeNode.FeatureName = (m_pITable as IObjectClass).AliasName;
                    string sAttriTableName = (m_pITable as IDataset).Name;
                    pFeatureCodeNode.FeatureCode = MetaDataFile.GetFeatureCodeByName(sAttriTableName);
                    ///数据表名称
                    pFeatureCodeNode.TableName    = sAttriTableName;
                    pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("NoneGeometry");
                }

                return(pFeatureCodeNode);
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// 从mdb到vct转换时,初始化图层列表
        /// </summary>
        private bool InitialFeatureList()
        {
            try
            {
                if (m_pIDataset == null)
                    return false;
                m_FeatureList = new List<TableLayer>();
                IEnumDataset pEnumDataset = m_pIDataset.Subsets;
                IDataset pSet = pEnumDataset.Next();
                while (pSet != null)
                {
                    FeatureLayer pFeatureLayer = null;
                    IFeatureClass pFeatureCls = pSet as IFeatureClass;


                    string sGeometryType = "";
                    ///从配置文件获取要素类型
                    Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.MetaTabls[pSet.Name] as Metadata.MetaTable;
                    if (pMetaTable != null)
                    {
                        sGeometryType = pMetaTable.Type;
                    }
                    else
                    {
                        ///如果不属于标准的数据则不处理
                        pSet = pEnumDataset.Next();
                        continue;
                    }
                    ///根据要素类型创建vct空间数据节点
                    esriGeometryType pFeatureType = pFeatureCls.ShapeType;
                    if (pFeatureType == esriGeometryType.esriGeometryLine
                        || pFeatureType == esriGeometryType.esriGeometryPolyline)
                    {
                        ///构造线节点
                        pFeatureLayer = new LineLayer();
                        if (sGeometryType == "")
                            sGeometryType = "Line";
                    }
                    else if (pFeatureType == esriGeometryType.esriGeometryPolygon)
                    {
                        //构造面节点
                        pFeatureLayer = new PolygonLayer();
                          if (sGeometryType == "")
                            sGeometryType = "Polygon"; 
                    }
                    else if (pFeatureType == esriGeometryType.esriGeometryPoint)
                    {
                        pFeatureLayer = new PointLayer();
                        if (sGeometryType == "")
                            sGeometryType = "Point"; 
                    }
                   
                    ////注记图层
                    if (pFeatureCls.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        pFeatureLayer = new AnnotationLayer();
                        pFeatureLayer.GeometryType = "Annotation";
                    }

                    pFeatureLayer.CutGeometry =m_cutGeometry;
                    //挂接空间数据表
                    pFeatureLayer.Table = pSet as ITable;
                    pFeatureLayer.GeometryType = sGeometryType;
                    pFeatureLayer.IsCut = m_bCut;
                    pFeatureLayer.FeatureCode = MetaDataFile.GetFeatureCodeByName(pSet.Name);
                    pFeatureLayer.UpdateFieldIndex();

                    m_FeatureList.Add(pFeatureLayer);
                    pSet = pEnumDataset.Next();
                }

                ///处理属性表集合
                IEnumDataset pAttriTalbelDataSet=  m_pIWorkspace.get_Datasets(esriDatasetType.esriDTTable);
                IDataset pAttriDataset = pAttriTalbelDataSet.Next();
                while (pAttriDataset != null)
                 {
                        TableLayer pAttributeTalbe = new TableLayer();

                        ///从配置文件获取要素类型
                        Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.MetaTabls[pAttriDataset.Name] as Metadata.MetaTable;
                        if (pMetaTable != null)
                        {
                            pAttributeTalbe.GeometryType = pMetaTable.Type;
                            pAttributeTalbe.Table = pAttriDataset as ITable;
                            pAttributeTalbe.UpdateFieldIndex();
                            m_FeatureList.Add(pAttributeTalbe);
                        }
                     pAttriDataset = pAttriTalbelDataSet.Next();
                 }
                return true;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return false;
            }
        }