Beispiel #1
0
		/// <summary>
		/// 连接GDB数据源
		/// </summary>
		public IWorkspace ConnectWorkspace()
        {
            IWorkspaceFactory factory = new AccessWorkspaceFactoryClass();
            try
            {
                return factory.OpenFromFile(m_strFilePathName, 0);
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(exception1);
                LogAPI.WriteErrorLog(ex);
                //ProjectData.ClearProjectError();
            }
            return null;
		}
Beispiel #2
0
        /// <summary>
        /// 连接GDB数据源
        /// </summary>
        private IWorkspace ConnectWorkspace()
        {
            IWorkspaceFactory factory = new FileGDBWorkspaceFactoryClass();

            try
            {
                return(factory.OpenFromFile(m_strFilePathName, 0));
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(exception1);
                LogAPI.WriteErrorLog(ex);
                //ProjectData.ClearProjectError();
            }
            return(null);
        }
Beispiel #3
0
		/// <summary>
		/// 创建数据集
		/// </summary>
		/// <param name="headNode">VCT头节点</param>
        public Dataset CreateDataset(HeadNode headNode, string strName)
        {
            if (headNode == null)
                return null;
            try
            {
                m_Dataset = new Dataset(m_pIWorkspace);
                if (m_Dataset.CreateESRIDataset(strName, headNode))
                    return m_Dataset;

                return m_Dataset;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 执行转换
        /// </summary>
        /// <param name="bIgnoreHeadError">是否忽略头文件的错误</param>
        /// <returns></returns>
        public EnumVCT2MDBExchangeInfo Exchange(bool bAllowDefaultProjection)
        {
            ///指示当前是否在读取VCT实体
            bool bIsReadEntity = false;
            ///指示当前是否在读取VCT属性
            bool bIsReadAtti = false;
            try
            {
                //读取头节点
                FileData.HeadNode headNode = m_VCTFile.ReadHeadNode();
                if (headNode != null)
                {
                    //创建数据集
                    ESRIData.Dataset dataset = m_MDBFile.CreateDataset(headNode, m_strDataSetName);

                    ///数据集的空间参考创建失败
                    if (dataset.ESRIDataset==null)
                    {
                        return EnumVCT2MDBExchangeInfo.DATASETERROR;
                    }
                    IGeoDataset pDataset = dataset.ESRIDataset as IGeoDataset;
                    if (pDataset!=null&&
                     pDataset.SpatialReference is UnknownCoordinateSystemClass && !bAllowDefaultProjection)
                    {
                        return EnumVCT2MDBExchangeInfo.PROJECTIONERROR;
                    }
                    if (dataset != null)
                    {
                        //读取要素参数节点和表结构节点
                        Hashtable arrFeatureCodeNode = m_VCTFile.ReadFeatureCodeNodes();
                        ///读取要素代码错误
                        if (arrFeatureCodeNode == null)
                        {
                            return EnumVCT2MDBExchangeInfo.FEATURECODEERROR;
                        }

                        List<FileData.TableStructureNode> arrTableStructureNode = m_VCTFile.ReadTableStructureNodes();
                        ///读取要素代码错误
                        if (arrTableStructureNode == null)
                        {
                            return EnumVCT2MDBExchangeInfo.FEATUREATRRIBUTE;
                        }


                        if (arrFeatureCodeNode != null && arrTableStructureNode != null)
                        {
                            //创建图层
                            //ESRIData.FeatureLayerFactory featureLayerFactory = new ESRIData.FeatureLayerFactory(dataset.Workspace);

                            //featureLayerFactory.CreateFeatureLayers(arrTableStructureNode, arrFeatureCodeNode);
                            //dataset.LayerFactory = featureLayerFactory;
                            dataset.CreateFeatureLayers(arrTableStructureNode, arrFeatureCodeNode);

                            //读取空间实体节点
                            string strFeatureCode = "";//上一个实体所属图层的要素代码
                            ESRIData.FeatureLayer featureLayer = null;
                            ESRIData.TableLayer tableLayer = null;
                            FileData.EntityNode entityNode;

                            bIsReadEntity = true;///开始读取实体
                            while ((entityNode = m_VCTFile.ReadEntityNode()) != null)
                            {
                                //获取实体所属图层
                                if (strFeatureCode != entityNode.FeatureCode)
                                    tableLayer = dataset.GetFeatureLayerByCode(entityNode.FeatureCode);

                                //创建空间实体对象
                                featureLayer = tableLayer as FeatureLayer;
                                if (featureLayer != null)
                                {
                                    featureLayer.CreateFeatureEntity(entityNode);
                                }
                                strFeatureCode = entityNode.FeatureCode;
                            }

                            //读取属性节点
                            FileData.TableNode tableNode = null;
                            bIsReadAtti = true;///开始读取VCT属性
                            while ((tableNode = m_VCTFile.ReadTableNode()) != null)
                            {
                                //获取属性表对象
                                tableLayer = dataset.GetFeatureLayerByName(tableNode.TableName);
                                featureLayer = tableLayer as FeatureLayer;
                                if (featureLayer != null)
                                {
                                    //读取数据表记录
                                    //FileData.RecordNode recordNode = null;
                                    //while ((recordNode = m_VCTFile.ReadRecordNode()) != null)
                                    //{
                                    //    ESRIData.FeatureEntity featureEntity = featureLayer.GetFeatureEntityByID(recordNode.EntityID);
                                    //    featureEntity.AttachAttribute(recordNode);
                                    //}
                                    List<FileData.RecordNode> arrRecordNode = m_VCTFile.ReadRecordNodes();
                                    if (arrRecordNode.Count > 0)
                                    {
                                        arrRecordNode.Sort();

                                        List<ESRIData.FeatureEntity> arrFeatureEntity = featureLayer.GetFeatureEntitys();
                                        if (arrFeatureEntity.Count > 0)
                                        {
                                            arrFeatureEntity.Sort();

                                            int j = 0;
                                            for (int i = 0; i < arrFeatureEntity.Count; i++)
                                            {
                                                for (; j < arrRecordNode.Count; j++)
                                                {

                                                    if (arrFeatureEntity[i].EntityID == arrRecordNode[j].EntityID)
                                                        arrFeatureEntity[i].AttachAttribute(arrRecordNode[j], featureLayer.StructureNode);
                                                    else if (arrFeatureEntity[i].EntityID < arrRecordNode[j].EntityID)
                                                    {
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        //插入
                                                    }

                                                }
                                            }
                                            arrFeatureEntity.Clear();
                                            arrFeatureEntity = null;
                                        }
                                        else
                                        {
                                            //插入
                                        }
                                        arrRecordNode.Clear();
                                        arrRecordNode = null;
                                    }
                                }
                                else
                                {
                                    ///add by zengping 2011-4-24添加属性记录
                                    if (tableLayer != null)
                                    {
                                        List<FileData.RecordNode> arrRecordNode = m_VCTFile.ReadRecordNodes();
                                        foreach (FileData.RecordNode Recorditem in arrRecordNode)
                                        {
                                            tableLayer.InsertAttibuteTableRecord(Recorditem);
                                        }
                                        arrRecordNode.Clear();
                                        arrRecordNode = null;
                                    }
                                    else
                                        tableNode = null;
                                }
                            }
                            tableLayer = null;
                            arrFeatureCodeNode.Clear();
                            arrTableStructureNode.Clear();
                            arrTableStructureNode = null;
                            arrFeatureCodeNode = null;
                            if (bAllowDefaultProjection && dataset.Projection.SpatialReference is UnknownCoordinateSystemClass)
                                return EnumVCT2MDBExchangeInfo.SUCCESSWITHDEFAULTPROJECTION;
                            else
                                return EnumVCT2MDBExchangeInfo.EXCHANGESUCCESS;
                        }
                        dataset.Dispose();
                    }
                    else
                    {
                        ///获取数据集错误
                        return EnumVCT2MDBExchangeInfo.DATASETERROR;
                    }
                    headNode = null;
                }
                else
                {
                    return EnumVCT2MDBExchangeInfo.HEADFILEERROR;
                }

                return  EnumVCT2MDBExchangeInfo.EXCHANGEFAIL;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                ///读取实体过程中出错
                if (bIsReadEntity && !bIsReadAtti)
                    return EnumVCT2MDBExchangeInfo.FEATUREENTY;
                    ///读取属性过程中出错
                else if (bIsReadEntity && bIsReadAtti)
                    return EnumVCT2MDBExchangeInfo.FEATUREATRRIBUTE;
                return  EnumVCT2MDBExchangeInfo.EXCHANGUNKNOWEERROR;
            }
            finally
            {
                GC.Collect();
            }
        }
Beispiel #5
0
/*
        /// <summary>
        /// 处理面实体中引用线对象的标识码
        /// </summary>
        /// <param name="arrLineNode">VCT线实体节点集合</param>
        /// <param name="arrFeatureCode">关联图层要素编码集合</param>
        /// <param name="arrLineNodeEx">VCT面实体中的线实体节点集合</param>
        private void MatchPolygonToLine(ref List<FileData.LineNode> arrLineNode, List<string> arrFeatureCode, ref List<FileData.LineNodeEx> arrLineNodeEx)
        {

            
            if (arrFeatureCode != null && arrFeatureCode.Count > 0)
            {
                List<FileData.LineNode> arrLinkLineNode = new List<FileData.LineNode>();
                for (int i = 0; i < arrLineNode.Count; i++)
                {
                    if (arrFeatureCode.Contains(arrLineNode[i].FeatureCode))
                    {
                        arrLinkLineNode.Add(arrLineNode[i]);
                    }
                }
                if (arrLinkLineNode.Count > 0)
                {
                    //排序
                    arrLinkLineNode.Sort();
                    arrLineNodeEx.Sort();

                    //更新构面线的标识码
                    int j = 0;
                    for (int i = 0; i < arrLinkLineNode.Count; i++)
                    {
                        for (; j < arrLineNodeEx.Count; j++)
                        {
                            //必须是未找到标识码的
                            if (arrLineNodeEx[j].EntityID == -1)
                            {
                                if (arrLinkLineNode[i] == arrLineNodeEx[j])
                                {
                                    arrLineNodeEx[j].IsFromLine = true;
                                    arrLineNodeEx[j].EntityID = arrLinkLineNode[i].EntityID;
                                }
                                else if (arrLinkLineNode[i] > arrLineNodeEx[j])
                                {

                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                    //反向
                    List<FileData.LineNodeEx> arrLineNodeExReverse = new List<FileData.LineNodeEx>();
                    for (int i = 0; i < arrLineNodeEx.Count; i++)
                    {
                        //必须是未找到标识码的
                        if (arrLineNodeEx[i].EntityID == -1)
                        {
                            FileData.LineNodeEx lineNodeEx = arrLineNodeEx[i];
                            lineNodeEx.Reverse();
                            arrLineNodeExReverse.Add(lineNodeEx);
                        }
                    }
                    arrLineNodeExReverse.Sort();//反向后排序
                    j = 0;
                    for (int i = 0; i < arrLinkLineNode.Count; i++)
                    {
                        for (; j < arrLineNodeExReverse.Count; j++)
                        {
                            if (arrLinkLineNode[i] == arrLineNodeExReverse[j])
                            {
                                arrLineNodeExReverse[j].IsFromLine = true;
                                arrLineNodeExReverse[j].EntityID = arrLinkLineNode[i].EntityID;
                            }
                            else if (arrLinkLineNode[i] > arrLineNodeExReverse[j])
                            {
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    arrLineNodeEx.Clear();
                    for (int i = 0; i < arrLineNodeExReverse.Count; i++)
                    {
                        //必须是未找到标识码的
                        if (arrLineNodeExReverse[i].EntityID == -1)
                        {
                            arrLineNodeEx.Add(arrLineNodeExReverse[i]);
                        }
                    }
                }
            }
            return arrLineNodeEx;
        }
*/
        //public FileData.LineNodeEx CloneLineNodeEx(FileData.LineNodeEx lineNodeExSource)
        //{
        //    //m_InitiallyLineNode = this;
            

        //    try
        //    {
        //        MemoryStream stream = new MemoryStream();
        //        BinaryFormatter formatter = new BinaryFormatter();
        //        formatter.Serialize(stream, lineNodeExSource);
        //        stream.Position = 0;

        //        FileData.LineNodeEx lineNodeEx = formatter.Deserialize(stream) as FileData.LineNodeEx;

        //        lineNodeEx.InitiallyLineNode = lineNodeExSource;
        //        return lineNodeEx;
        //    }
        //    catch (Exception ex)
        //    {
        //        LogAPI.WriteErrorLog(ex);
        //    }
        //     /* 
        //    try
        //    {
        //        FileData.LineNodeEx lineNodeEx = new FileData.LineNodeEx();
        //        lineNodeEx.IsReverse = lineNodeExSource.IsReverse;
        //        lineNodeEx.PolygonID = lineNodeExSource.PolygonID;
        //        lineNodeEx.LineIndex = lineNodeExSource.LineIndex;
        //        lineNodeEx.IsFromLine = lineNodeExSource.IsFromLine;

        //        lineNodeEx.LineType = lineNodeExSource.LineType;
        //        lineNodeEx.SegmentNodes = new FileData.SegmentNodes();
        //        for (int i = 0; i < lineNodeExSource.SegmentNodes.Count; i++)
        //        {
        //            lineNodeEx.SegmentNodes.Add(lineNodeExSource.SegmentNodes[i]);
        //            //BrokenLineNode brokenLineNode1 = this.SegmentNodes[i] as BrokenLineNode;
        //            //if (brokenLineNode1 != null)
        //            //{
        //            //    BrokenLineNode brokenLineNode2 = new BrokenLineNode();
        //            //    brokenLineNode2.PointInfoNodes = new PointInfoNodes();
        //            //    for (int j = 0; j < brokenLineNode1.PointInfoNodes.Count; j++)
        //            //    {
        //            //        PointInfoNode pointInfoNode = new PointInfoNode();
        //            //        pointInfoNode.X = brokenLineNode1.PointInfoNodes[j].X;
        //            //        pointInfoNode.Y = brokenLineNode1.PointInfoNodes[j].Y;
        //            //        brokenLineNode2.PointInfoNodes.Add(pointInfoNode);
        //            //    }
        //            //    lineNodeEx.SegmentNodes.Add(brokenLineNode2);
        //            //}
        //        }

        //        lineNodeEx.EntityID = lineNodeExSource.EntityID;
        //        lineNodeEx.FeatureCode = lineNodeExSource.FeatureCode;
        //        lineNodeEx.Representation = lineNodeExSource.Representation;

        //        lineNodeEx.InitiallyLineNode = lineNodeExSource;
        //        return lineNodeEx;
        //    }
        //    catch (Exception ex)
        //    {
        //        LogAPI.WriteErrorLog(ex);
        //    }*/
        //    return null;
        //}

/*

        /// <summary>
        /// 处理面实体中引用线对象的标识码
        /// </summary>
        /// <param name="arrLineNodeExNew">VCT面实体中的线实体节点集合(需要新建)</param>
        private void MatchPolygonToLine(ref List<FileData.LineNodeEx> arrLineNodeExNew)
        {
            List<FileData.LineNodeEx> arrLineNodeNewClone = new List<VCT.FileData.LineNodeEx>();
            for (int i = 0; i < arrLineNodeExNew.Count; i++)
            {
                //克隆对象,并反向
                FileData.LineNodeEx lineNodeEx = CloneLineNodeEx(arrLineNodeExNew[i]);//.Clone() as FileData.LineNodeEx;
                if (lineNodeEx != null)
                {
                    lineNodeEx.Reverse();
                    arrLineNodeNewClone.Add(lineNodeEx);
                }
            }

            arrLineNodeExNew.Sort();
            arrLineNodeNewClone.Sort();

            int j = 0;
            for (int i = 0; i < arrLineNodeExNew.Count; i++)
            {
                if (arrLineNodeExNew[i].EntityID == -1)
                {
                    //需要创建要素编码
                    arrLineNodeExNew[i].EntityID = this.m_nNewEntityID;
                    ////未做合并处理
                    //m_VCTFile.WritePolygonLineNode(arrLineNodeExNew[i]);
                }
                for (; j < arrLineNodeNewClone.Count; j++)
                {
                    if (arrLineNodeNewClone[j].InitiallyLineNode.EntityID == -1)
                    {
                        if (arrLineNodeExNew[i] == arrLineNodeNewClone[j])
                        {
                            arrLineNodeNewClone[j].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
                            arrLineNodeNewClone[j].InitiallyLineNode.Reverse();
                            //arrLineNodeNewClone[j].InitiallyLineNode.IsReverse = arrLineNodeNewClone[j].IsReverse;

                            arrLineNodeNewClone[j].InitiallyLineNode.OtherPolygonLineNode = arrLineNodeExNew[i];
                            arrLineNodeExNew[i].OtherPolygonLineNode = arrLineNodeNewClone[j].InitiallyLineNode;
                        }
                        if (arrLineNodeExNew[i] > arrLineNodeNewClone[j])
                        {
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }



            //for (int i = 0; i < arrLineNodeExNew.Count; i++)
            //{
            //    if ((arrLineNodeExNew[i].InitiallyLineNode == null && arrLineNodeExNew[i].EntityID == -1) ||                      //非克隆对象
            //        (arrLineNodeExNew[i].InitiallyLineNode != null && arrLineNodeExNew[i].InitiallyLineNode.EntityID == -1))      //克隆对象
            //    {
            //        if (i > 0)
            //        {
            //            if (arrLineNodeExNew[i] == arrLineNodeExNew[i - 1])
            //            {
            //                arrLineNodeExNew[i].EntityID = arrLineNodeExNew[i - 1].EntityID;
            //                if (arrLineNodeExNew[i].InitiallyLineNode != null)
            //                {
            //                    //arrLineNodeExNew[i]是克隆对象,需要更新原始对象的标识码和方向标识
            //                    arrLineNodeExNew[i].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
            //                    arrLineNodeExNew[i].InitiallyLineNode.IsReverse = arrLineNodeExNew[i].IsReverse;
            //                }



                            
            //                continue;
            //            }
            //        }
            //        //需要创建要素编码
            //        arrLineNodeExNew[i].EntityID = this.NewEntityID;
            //        if (arrLineNodeExNew[i].InitiallyLineNode != null)
            //        {
            //            //arrLineNodeExNew[i]是克隆对象,需要更新原始对象的标识码和方向标识
            //            arrLineNodeExNew[i].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
            //            arrLineNodeExNew[i].InitiallyLineNode.IsReverse = arrLineNodeExNew[i].IsReverse;
            //        }
            //        m_VCTFile.WritePolygonLineNode(arrLineNodeExNew[i]);
            //    }
            //}
        }
        */
        ///// <summary>
        ///// 处理面实体中引用线对象的标识码
        ///// </summary>
        ///// <param name="arrLineNode">VCT线实体节点集合</param>
        //private void WritePolygonLineNodes(ref List<FileData.LineNodeEx> arrLineNode)
        //{
        //    ////按标识码、在面的边界线集合中的索引排序
        //    FileData.LineNodeExComparer lineNodeExComparer = new FileData.LineNodeExComparer();
        //    arrLineNode.Sort(lineNodeExComparer);

        //    FileData.LineNodeEx lineNode = null;
        //    for (int i = 0; i < arrLineNode.Count; i++)
        //    {
        //        if (lineNode == null)
        //        {
        //            lineNode = arrLineNode[i];
        //        }
        //        else
        //        {
        //            if (arrLineNode[i].EntityID == lineNode.EntityID)
        //            {
        //                lineNode.SegmentNodes.AddRange(arrLineNode[i].SegmentNodes);
        //            }
        //            else
        //            {
        //                m_VCTFile.WritePolygonLineNode(lineNode);
        //                lineNode = arrLineNode[i];
        //            }

        //            if (i == arrLineNode.Count - 1)
        //            {
        //                m_VCTFile.WritePolygonLineNode(lineNode);
        //            }
        //        }
        //    }
        //}

 



        /// <summary>
        /// 执行转换
        /// </summary>
        public EnumMDB2VCTExchangeInfo Exchange()
        {
            ///指示当前转换的执行位置
            int nExcutePosition = 0;
            ///1.表结构 2.点 3.线 4.面
            try
            {
                //获取PGDB数据集
                m_dataset =  m_MDBFile.GetDataset();
                if (m_dataset != null)
                {
                    //获取当前数据的最大实体标识码
                    this.m_nNewEntityID = m_dataset.GetMaxEntityID() + 1;
                    //获取VCT头节点
                    ESRIData.Projection projection = m_dataset.GetProjection();
                    if (projection != null)
                    {
                        FileData.HeadNode headNode = projection.GetHeadNode();
                        ///生成头文件错误
                        if (headNode == null)
                        {
                            return EnumMDB2VCTExchangeInfo.HEADFILEERROR;
                        }
                        //1、写入VCT头节点
                        m_VCTFile.WriteHeadNode(headNode);

                        //获取图层集合
                        ESRIData.TableLayer tableLayer;
                        m_nLayerCount = m_dataset.GetLayerCount();
                        List<FileData.FeatureCodeNode> arrFeatureCodeNode = new List<FileData.FeatureCodeNode>();
                        List<FileData.TableStructureNode> arrTableStructureNode = new List<FileData.TableStructureNode>();

                        nExcutePosition++;
                        for (int i = 0; i < m_nLayerCount; i++)
                        {
                            //获取图层对象
                            tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                            //获取图层要素参数信息
                            FileData.FeatureCodeNode featureCodeNode = tableLayer.GetFeatureCodeNode();
                            arrFeatureCodeNode.Add(featureCodeNode);
                            //获取图层表结构信息
                            FileData.TableStructureNode tableStructureNode = tableLayer.StructureNode;
                            arrTableStructureNode.Add(tableStructureNode);
                        }
                        //2、写入VCT要素参数节点
                        m_VCTFile.WriteFeatureCodeNodes(arrFeatureCodeNode);
                        //3、写入VCT表结构节点
                        m_VCTFile.WriteTableStructureNode(arrTableStructureNode);

                        ///释放不在使用的对象,减少内存使用率 add by 曾平
                        //m_VCTFile.Flush();
                        arrFeatureCodeNode.Clear();
                        arrTableStructureNode.Clear();

                        nExcutePosition++;

                        //4、写入点实体节点
                        for (int i = 0; i < m_nLayerCount; i++)
                        {
                            //获取图层对象
                            tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                            ESRIData.PointLayer pointLayer = tableLayer as ESRIData.PointLayer;
                            if (pointLayer != null)
                            {
                                if (pointLayer.FeatureEntys != null)
                                {
                                    for (int j = 0; j < pointLayer.FeatureEntys.Count; j++)
                                    {
                                        m_VCTFile.WritePointNode(pointLayer.FeatureEntys[j].GetEntityNode() as FileData.PointNode);
                                    }
                                }
                            }
                        }

                        nExcutePosition++;
                        ////5、写入线实体节点
                        //List<FileData.LineNode> arrLineNode = new List<FileData.LineNode>();
                        for (int i = 0; i < m_nLayerCount; i++)
                        {
                            //获取图层对象
                            tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                            ESRIData.LineLayer lineLayer = tableLayer as ESRIData.LineLayer;
                            if (lineLayer != null)
                            {
                                if (lineLayer.FeatureEntys != null)
                                {
                                    for (int j = 0; j < lineLayer.FeatureEntys.Count; j++)
                                    {
                                        FileData.LineNode lineNode = lineLayer.FeatureEntys[j].GetEntityNode() as FileData.LineNode;
                                        if (lineNode != null)
                                        {
                                            m_VCTFile.WriteLineNode(lineNode);
                                        }
                                    }
                                }
                            }
                        }

                        ////处理面实体中引用线对象的标识码
                        ////List<FileData.PolygonNode> arrPolygonNode = MatchPolygonToLine(dataset, ref arrLineNode);
                        ////6、写入面实体节点
                        nExcutePosition++;
                        WritePolygonNodes pWritePolygonNodes = new WritePolygonNodes(m_dataset, this.m_pTempFile, this.m_VCTFile, this.m_nNewEntityID);
                        //pWritePolygonNodes.WriteCommplete += new WriteCommpleteEventHandler(WritePolygonNodes_WriteCommplete);
                        pWritePolygonNodes.Write();

                        WritePolygonNodes_WriteCommplete(true);
                        return EnumMDB2VCTExchangeInfo.EXCHANGESUCCESS;

                    }
                    else
                    {
                        return EnumMDB2VCTExchangeInfo.PROJCTIONERROR;
                    }
                }
                else
                {
                    return EnumMDB2VCTExchangeInfo.DATASETERROR;
                }

            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                EnumMDB2VCTExchangeInfo pInfo = EnumMDB2VCTExchangeInfo.EXCHANGUNKNOWEERROR;
                if (nExcutePosition == 1)
                    pInfo = EnumMDB2VCTExchangeInfo.FEATUREINFOERROR;
                else if (nExcutePosition == 2)
                    pInfo = EnumMDB2VCTExchangeInfo.POINTERROR;
                else if (nExcutePosition == 3)
                    pInfo = EnumMDB2VCTExchangeInfo.LINEERROR;
                else if (nExcutePosition == 4)
                    pInfo = EnumMDB2VCTExchangeInfo.PLOYGONERROR;

                return pInfo;
            }
        }
Beispiel #6
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;
                            LogAPI.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;
                            LogAPI.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);
                //}
            }
        }
Beispiel #7
0
        //private bool IsFilishWritePolygon = false;
        //private void WritePolygonCompleted(object sender, RunWorkerCompletedEventArgs e)
        //{
        //    TimeSpan span = DateTime.Now - this.timeBeginPolygon;
        //    LogAPI.WriteLog("写入构面线临时数据耗时" + span.ToString());

        //    if (IsFilishWritePolygon == false)
        //        IsFilishWritePolygon = true;
        //    if (IsFilishWriteLine == true)
        //        WritePolygonLineCompleted();

        //}

        //private bool IsFilishWriteLine = false;
        //private void WriteLineCompleted(object sender, RunWorkerCompletedEventArgs e)
        //{
        //    TimeSpan span = DateTime.Now - this.timeBeginLine;
        //    LogAPI.WriteLog("写入引用线临时数据耗时" + span.ToString());
        //    if (IsFilishWriteLine == false)
        //        IsFilishWriteLine = true;
        //    if (IsFilishWritePolygon == true)
        //        WritePolygonLineCompleted();
        //}

        //写入面层和线层历史数据异步操作完成回调函数
        private void WritePolygonLineCompleted()
        {
            //匹配面实体中的构面线和线图层中的线实体
            DateTime dateTime1 = DateTime.Now;

            m_pTempFile.MatchPolygonToLine();
            DateTime dateTime2 = DateTime.Now;
            TimeSpan span      = dateTime2 - dateTime1;

            //MessageBox.Show(span.ToString());
            LogAPI.WriteLog("匹配面实体中的构面线和线图层中的线实体耗时" + span.ToString());



            //处理面图层中构面线之间的关系
            dateTime1 = DateTime.Now;
            int nMaxEntityID = this.m_nNewEntityID;

            m_pTempFile.MatchPolygonLine(/*ref this.m_nNewEntityID*/);
            dateTime2 = DateTime.Now;
            span      = dateTime2 - dateTime1;
            LogAPI.WriteLog("处理面图层中构面线之间的关系耗时" + span.ToString());
            //合并线节点
            dateTime1 = DateTime.Now;
            m_pTempFile.MergeLineEntityID(ref this.m_nNewEntityID);
            dateTime2 = DateTime.Now;
            span      = dateTime2 - dateTime1;
            LogAPI.WriteLog("合并线节点耗时" + span.ToString());
            //处理环线中首尾线段
            dateTime1 = DateTime.Now;
            m_pTempFile.UpdateRing();
            dateTime2 = DateTime.Now;
            span      = dateTime2 - dateTime1;
            LogAPI.WriteLog("处理环线中首尾线段耗时" + span.ToString());

            //处理环线中的自闭合线
            dateTime1 = DateTime.Now;
            m_pTempFile.UpdateClosedLineNode();
            dateTime2 = DateTime.Now;
            span      = dateTime2 - dateTime1;
            LogAPI.WriteLog("处理环线中的自闭合线耗时" + span.ToString());

            if (nMaxEntityID > 0)
            {
                //处理线段在一个面中连续,另一个面中不连续的情况
                dateTime1 = DateTime.Now;
                m_pTempFile.SplitLineNode();
                dateTime2 = DateTime.Now;
                span      = dateTime2 - dateTime1;
                LogAPI.WriteLog("处理线段在一个面中连续,另一个面中不连续的情况耗时" + span.ToString());
                //更新反向线的索引
                dateTime1 = DateTime.Now;
                m_pTempFile.UpdateReverseLineEntityID();
                dateTime2 = DateTime.Now;
                span      = dateTime2 - dateTime1;
                LogAPI.WriteLog("更新反向线的索引耗时" + span.ToString());
                //写入节点
                dateTime1 = DateTime.Now;
                m_pTempFile.WritePolygonLineNodes(m_VCTFile);
                dateTime2 = DateTime.Now;
                span      = dateTime2 - dateTime1;
                LogAPI.WriteLog("写入面图层的线节点节点耗时" + span.ToString());
            }

            //写入面实体节点
            dateTime1 = DateTime.Now;
            m_pTempFile.WritePolygonNodes(m_VCTFile);
            dateTime2 = DateTime.Now;
            span      = dateTime2 - dateTime1;
            LogAPI.WriteLog("写入面节点节点耗时" + span.ToString());


            this.m_nLayerIndex++;

            Write();
        }