Пример #1
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);
                //}
            }
        }
Пример #2
0
        /// <summary>
        /// 写入多边形节点
        /// </summary>
        /// <param name="pVCTFile">VCT文件对象</param>
        public void WritePolygonNodes(VCTFile pVCTFile)
        {
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                PolygonNodeTable pPolygonNodeTable = new PolygonNodeTable(m_pOleDbConnection);
                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection);

                //按面标识码
                string strPolygonNodeOrderBy = pPolygonNodeTable.FieldName_EntityID;
                DataTable dataTablePolygon = pPolygonNodeTable.GetRecords("", "", strPolygonNodeOrderBy);

                //按面标识码、在面的边界线集合中的索引排序
                string strLineNodeExOrderBy = pLineNodeExTable.FieldName_PolygonID + "," + pLineNodeExTable.FieldName_LineIndex;
                DataTable dataTableLine = pLineNodeExTable.GetRecords(pLineNodeExTable.FieldName_PolygonID + ",-" + pLineNodeExTable.FieldName_EntityID + "*" + pLineNodeExTable.FieldName_IsReverse, "", "", strLineNodeExOrderBy);

                PolygonNodeSimple polygonNode = null;
                //LineNodeEx lineNode = null;
                //LineNodeEx lineNodeUp = null;
                int nPolygonID = -1;
                int nEntityID = -1;
                int nEntityIDUp = -1;
                int j = 0;
                while (dataTablePolygon.Rows.Count > 0)
                {
                    for (int i = 0; i < dataTablePolygon.Rows.Count; i++)
                    {
                        polygonNode = new PolygonNodeSimple();
                        pPolygonNodeTable.GetEntityNodeByDataRow(dataTablePolygon.Rows[i], ref polygonNode);

                        while (dataTableLine.Rows.Count > 0)
                        {
                            for (; j < dataTableLine.Rows.Count; j++)
                            {
                                //lineNodeUp = null;
                                //lineNode = new LineNodeEx();
                                //pLineNodeExTable.GetLineNodeByDataRow(dataTableLine.Rows[j], ref lineNode, false);
                                nPolygonID = Convert.ToInt32(dataTableLine.Rows[j][0]);
                                nEntityID = Convert.ToInt32(dataTableLine.Rows[j][1]);

                                if (nPolygonID == polygonNode.EntityID)
                                {
                                    if (nEntityIDUp != -1)
                                    {
                                        if (nEntityIDUp == nEntityID)
                                        {
                                            continue;
                                        }
                                    }
                                    polygonNode.LineNodes.Add(nEntityID);
                                }
                                else
                                {
                                    break;
                                }
                                nEntityIDUp = nEntityID;
                            }

                            if (j == dataTableLine.Rows.Count)
                            {
                                if (dataTableLine.Rows.Count < pLineNodeExTable.MaxRecordCount)
                                    break;
                                dataTableLine = pLineNodeExTable.GetNextRecords();
                                j = 0;
                            }
                            else
                                break;
                        }

                        pVCTFile.WritePolygonNode(polygonNode);
                    }
                    if (dataTablePolygon.Rows.Count < pPolygonNodeTable.MaxRecordCount)
                        break;
                    dataTablePolygon = pPolygonNodeTable.GetNextRecords();

                }

            }
        }