Пример #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;
            }
        }
Пример #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;
            }
        }
Пример #3
0
        /// <summary>
        /// 写入面节点
        /// </summary>
        public void Write()
        {
            if (m_pTempFile.DbConnection != null && m_pTempFile.DbConnection.State == ConnectionState.Open)
            {
                ESRIData.FeatureLayer featureLayer;
                while (this.m_nLayerIndex < m_nLayerCount)
                {
                    //获取图层对象
                    featureLayer = m_dataset.GetFeatureLayerByIndex(this.m_nLayerIndex) as ESRIData.FeatureLayer;
                    ESRIData.PolygonLayer polygonLayer = featureLayer as ESRIData.PolygonLayer;
                    if (polygonLayer != null)
                    {
                        List <ESRIData.FeatureEntity> arrFeatureEntity = polygonLayer.FeatureEntys;
                        if (arrFeatureEntity != null && arrFeatureEntity.Count > 0)
                        {
                            m_pTempFile.IsFirst = m_bIsFirst;

                            ////清除临时数据
                            PolygonNodeTable pPolygonNodeTable = new PolygonNodeTable(m_pTempFile.DbConnection, true, m_bIsFirst);
                            LineNodeExTable  pLineNodeExTable  = new LineNodeExTable(m_pTempFile.DbConnection, true, m_bIsFirst);
                            LineNodeTable    pLineNodeTable    = new LineNodeTable(m_pTempFile.DbConnection, true, m_bIsFirst);


                            ///处理每个图层下的所有要素
                            //using (BackgroundWorker workerPolygon = new BackgroundWorker())
                            //{
                            //    workerPolygon.DoWork += delegate
                            //    {
                            timeBeginPolygon = DateTime.Now;

                            int j = 1, n = 1;
                            FileData.PolygonNode polygonNode = null;
                            while (arrFeatureEntity.Count > 0)
                            {
                                polygonNode = arrFeatureEntity[0].GetEntityNode() as FileData.PolygonNode;
                                if (polygonNode != null)
                                {
                                    pPolygonNodeTable.AddRow(polygonNode);

                                    for (int k = 0; k < polygonNode.LineNodes.Count; k++)
                                    {
                                        polygonNode.LineNodes[k].LineIndex = k;
                                        pLineNodeExTable.AddRow(polygonNode.LineNodes[k]);
                                        if (n % pLineNodeExTable.MaxRecordCount == 0)
                                        {
                                            pLineNodeExTable.Save(true);
                                        }
                                        n++;
                                    }
                                }

                                //m_pTempFile.PolygonNodes.AddRow(polygonNode);
                                if (j % pPolygonNodeTable.MaxRecordCount == 0 || 1 == arrFeatureEntity.Count)
                                {
                                    //if (j == arrFeatureEntity.Count)
                                    pLineNodeExTable.Save(true);
                                    pPolygonNodeTable.Save(true);
                                }
                                arrFeatureEntity.RemoveAt(0);
                                j++;
                            }
                            TimeSpan span = DateTime.Now - this.timeBeginPolygon;
                            Logger.WriteLog("写入构面线临时数据耗时" + span.ToString());

                            //    };

                            //    workerPolygon.RunWorkerCompleted += WritePolygonCompleted;

                            //    workerPolygon.RunWorkerAsync();
                            //}


                            //保存关联的线图层中的线结点到临时图层/*
                            //using (BackgroundWorker workerLine = new BackgroundWorker())
                            //{
                            timeBeginLine = DateTime.Now;
                            //    workerLine.DoWork += delegate
                            //    {
                            SaveLineNodesToTemp(pLineNodeTable, featureLayer.StructureNode.TableName);
                            span = DateTime.Now - this.timeBeginLine;
                            Logger.WriteLog("写入引用线临时数据耗时" + span.ToString());

                            //    };

                            //    workerLine.RunWorkerCompleted += WriteLineCompleted;

                            //    workerLine.RunWorkerAsync();

                            //};

                            WritePolygonLineCompleted();

                            if (m_bIsFirst == true)
                            {
                                m_bIsFirst = false;
                            }
                        }
                        break;
                    }
                    else
                    {
                        this.m_nLayerIndex++;
                    }
                }
                //if (this.m_nLayerIndex == m_nLayerCount)
                //{
                //    m_pTempFile.Close();
                //    if (WriteCommplete != null)
                //        WriteCommplete(true);
                //}
            }
        }
Пример #4
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;
        }