Example #1
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;
            }
        }
Example #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;
            }
        }
Example #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)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }