Beispiel #1
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;
        }
Beispiel #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;
            }
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
        private void WritePolygonNodes_WriteCommplete(bool IsSuccessful)
        {
            ESRIData.TableLayer tableLayer;
            ESRIData.FeatureLayer featureLayer;
            //for (int i = 0; i < arrPolygonNode.Count; i++)
            //{
            //    m_VCTFile.WritePolygonNode(arrPolygonNode[i]);
            //}
            //7、写入注记实体节点
            for (int i = 0; i < m_nLayerCount; i++)
            {
                //获取图层对象
                tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                ESRIData.AnnotationLayer annotationLayer = tableLayer as ESRIData.AnnotationLayer;
                if (annotationLayer != null)
                {
                    if (annotationLayer.FeatureEntys == null) continue;
                    for (int j = 0; j < annotationLayer.FeatureEntys.Count; j++)
                    {
                        m_VCTFile.WriteAnnotationNode(annotationLayer.FeatureEntys[j].GetEntityNode() as FileData.AnnotationNode);
                        ////add by 曾平
                        //if (j % 1000 == 0)
                        //    m_VCTFile.Flush();
                    }
                    //m_VCTFile.Flush();
                }
            }
            //8、写入表属性记录节点
            for (int i = 0; i < m_nLayerCount; i++)
            {
                //获取图层对象
                tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                featureLayer = tableLayer as ESRIData.FeatureLayer;
                if (featureLayer != null)
                {
                    int j = 0;
                    m_VCTFile.WriteTableNode(featureLayer.GetTableNode());
                    if (featureLayer.FeatureEntys == null) continue;
                    for (j = 0; j < featureLayer.FeatureEntys.Count; j++)
                    {
                        m_VCTFile.WriteRecordNode(featureLayer.FeatureEntys[j].GetRecordNode(featureLayer.StructureNode), false);
                    }
                    //if (j < arrFeatureEntity.Count)
                    //    m_VCTFile.WriteRecordNode(arrFeatureEntity[j].GetRecordNode(), true);
                    //else
                    //    m_VCTFile.WriteRecordNode(null, true);

                    //m_VCTFile.Flush();
                }
                else if (tableLayer != null)
                {
                    m_VCTFile.WriteTableNode(tableLayer.GetTableNode());
                    if (tableLayer.RecordNodes != null)
                    {
                        foreach (FileData.RecordNode pRecorditem in tableLayer.RecordNodes)
                        {
                            m_VCTFile.WriteRecordNode(pRecorditem, false);
                        }
                    }

                    //m_VCTFile.Flush();
                }
                ///写入属性表结束标签
                m_VCTFile.WriteRecordNode(null, true);
            }

            //写入其他节点
            m_VCTFile.WriteVarcharNode();
            m_VCTFile.WriteStyleNode();


            m_VCTFile.CloseFile();

            //if (WriteCommplete != null)
            //    WriteCommplete(true);

            //return true
        }
Beispiel #5
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
                {
                    LogAPI.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)
            {
                LogAPI.WriteErrorLog(ex);
            }
            return null;
        }