예제 #1
0
파일: TempFile.cs 프로젝트: hy1314200/HyDM
        //public void UpdatePolygonClosedLineNode(LineNodeExTable pLineNodeExTable, int nBeginIndex, int nEndIndex/*, DataTable dataTable, DataTable dataTableTemp, LineNodeExTable pLineNodeExTableTemp*/)
        //{
        ////LineNode lineNodeTemp = null;
        //for (int j = nBeginIndex; j < nEndIndex; j++)
        //{
        //    LineNodeEx lineNode = new LineNodeEx();
        //    LineNodeEx lineNodeOther = null;
        //    //lineNodeTemp = lineNode as LineNode;
        //    pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[j], ref lineNode, false);
        //    if (lineNode.OrtherIndexID > -1 && lineNode.OrtherIndexID < dataTableTemp.Rows.Count)
        //    {
        //        lineNodeOther = new LineNodeEx();
        //        //lineNodeTemp = lineNodeOther as LineNode;
        //        pLineNodeExTableTemp.GetLineNodeByDataRow(dataTableTemp.Rows[lineNode.OrtherIndexID], ref lineNodeOther, false);
        //    }
        //    else
        //        lineNodeOther = null;
        //    pLineNodeExTable.ReverseLineNode(dataTable.Rows[j]);
        //    pLineNodeExTableTemp.ReverseLineNode(dataTableTemp.Rows[lineNode.OrtherIndexID]);
        //}
        //}
        /// <summary>
        /// 处理自闭合线问题(在不同面中的顺序不一致)
        /// </summary>
        public void UpdateClosedLineNode()
        {
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                ReverseLineNodeTable reverseLineNodeTable = new ReverseLineNodeTable(m_pOleDbConnection, true, false);

                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection);
                string strLineNodeExOrderBy = pLineNodeExTable.FieldName_PolygonID + "," + pLineNodeExTable.FieldName_LineIndex;
                string strWhere = pLineNodeExTable.FieldName_IsFromLine + "=-1 And " + pLineNodeExTable.FieldName_IsReverse + "=-1 And " + pLineNodeExTable.FieldName_OrtherLineNodeID + ">-1";
                DataTable dataTable = pLineNodeExTable.GetRecords(strWhere, "", strLineNodeExOrderBy);

                List<LineNodeEx> arrLineNodeEx = new List<LineNodeEx>();
                LineNodeEx lineNodeUp = null;
                LineNodeEx lineNodeCurrent = null;
                bool bNeedSave = false;
                int nReverseCount = 0;
                bool bAdded = false;
                while (dataTable.Rows.Count > 0)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        lineNodeCurrent = new LineNodeEx();
                        pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[i], ref lineNodeCurrent, false);

                        bAdded = false;
                        //是否需要处理(方向未反向,标识码一致且同属于另一个面)
                        //if (lineNodeCurrent.IsReverse == false)
                        //{
                            //if (lineNodeCurrent.OrtherIndexID > -1)
                            //{
                                if (lineNodeUp == null || (lineNodeCurrent.EntityID == lineNodeUp.EntityID))
                                {
                                    arrLineNodeEx.Add(lineNodeCurrent);
                                    bAdded = true;
                                }
                            //}
                        //}

                        if (bAdded == true)
                        {
                            if (lineNodeUp != null)
                            {
                                //判断当前线节点与上一线节点是否属于同一个面
                                if (lineNodeCurrent.PolygonID != lineNodeUp.PolygonID)
                                {
                                    UpdatePolygonClosedLineNode(ref arrLineNodeEx, reverseLineNodeTable, ref nReverseCount);
                                }
                            }
                        }
                        else
                        {
                            arrLineNodeEx.Clear();
                        }

                        lineNodeUp = lineNodeCurrent;
                    }

                    if (nReverseCount > reverseLineNodeTable.MaxRecordCount)
                    {
                        reverseLineNodeTable.Save(true);
                        bNeedSave = true;
                        nReverseCount = 0;
                    }

                    if (dataTable.Rows.Count < pLineNodeExTable.MaxRecordCount)
                        break;
                    dataTable = pLineNodeExTable.GetNextRecords();

                }

                UpdatePolygonClosedLineNode(ref arrLineNodeEx, reverseLineNodeTable, ref nReverseCount);
                if (nReverseCount > 0)
                {
                    reverseLineNodeTable.Save(true);
                    bNeedSave = true;
                }

                if (bNeedSave == true)
                {
                    //删除冗余记录
                    reverseLineNodeTable.DeleteSurplusRows();

                    //更新反向标识
                    string strCommand = "Update LineNodeEx Set IsReverse=0-IsReverse Where LineNodeID In ( Select LineNodeID From ReverseLineNode )";//反向
                    reverseLineNodeTable.ExecuteNonQuery(strCommand);
                }
            }
        }
예제 #2
0
파일: TempFile.cs 프로젝트: hy1314200/HyDM
        /// <summary>
        /// 合并线节点标识码
        /// </summary>
        //public void MergePolygonLineEntityID(ref LineNodeEx lineNodeBegin, int nIndexBegin, int nIndexEnd)
        //{
        //    if (lineNodeBegin != null && nIndexEnd > 0)
        //    {
        //        bool bNeedFind = true;
        //        int k = nIndexEnd;
        //        //LineNode lineNodeTemp = null;
        //        while (bNeedFind == true)
        //        {
        //            if (k <= nIndexBegin)
        //                break;
        //            LineNodeEx lineNodeK = new LineNodeEx();
        //            //lineNodeTemp = lineNodeK as LineNode;
        //            pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[k - 1], ref lineNodeK, false);
        //            LineNodeEx lineNodeKOther = null;
        //            if (lineNodeK.OrtherIndexID > -1 && lineNodeK.OrtherIndexID < dataTableTemp.Rows.Count)
        //            {
        //                lineNodeKOther = new LineNodeEx();
        //                //lineNodeTemp = lineNodeKOther as LineNode;
        //                pLineNodeExTableTemp.GetLineNodeByDataRow(dataTableTemp.Rows[lineNodeK.OrtherIndexID], ref lineNodeKOther, false);
        //            }
        //            else
        //                lineNodeKOther = null;
        //            //不仅仅是最后一个
        //            if ((lineNodeBeginOther != null && lineNodeKOther != null && lineNodeBeginOther.PolygonID == lineNodeKOther.PolygonID)
        //                || (lineNodeBeginOther == null && lineNodeKOther == null && lineNodeBegin.IsFromLine == false && lineNodeK.IsFromLine == false))
        //            {
        //                //合并线
        //                lineNodeK.EntityID = lineNodeBegin.EntityID;
        //                pLineNodeExTable.SetLineNodeEntityID(dataTable.Rows[k - 1], lineNodeBegin.EntityID);
        //                if (lineNodeK.IsReverse != lineNodeBegin.IsReverse)
        //                {
        //                    //若方向不一致
        //                    //lineNodeK.Reverse();
        //                    pLineNodeExTable.ReverseLineNode(dataTable.Rows[k - 1]);
        //                    //在另一个面中的对象也反向
        //                    //if (lineNodeKOther != null)
        //                    //    lineNodeKOther.Reverse();
        //                    if (lineNodeKOther != null)
        //                        pLineNodeExTableTemp.ReverseLineNode(dataTableTemp.Rows[lineNodeK.OrtherIndexID]);
        //                }
        //                k--;
        //            }
        //            else
        //                bNeedFind = false;
        //        }
        //        lineNodeBegin = null;
        //    }
        //}
        //public void MergePolygonLineEntityID(LineNodeExTable pLineNodeExTable, ref LineNodeEx lineNodeBegin, LineNodeEx lineNodeBeginOther, int nIndexBegin, int nIndexEnd, DataTable dataTable, DataTable dataTableTemp, LineNodeExTable pLineNodeExTableTemp)
        //{
        //    if (lineNodeBegin != null && nIndexEnd > 0)
        //    {
        //        bool bNeedFind = true;
        //        int k = nIndexEnd;
        //        //LineNode lineNodeTemp = null;
        //        while (bNeedFind == true)
        //        {
        //            if (k <= nIndexBegin)
        //                break;
        //            LineNodeEx lineNodeK = new LineNodeEx();
        //            //lineNodeTemp = lineNodeK as LineNode;
        //            pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[k - 1], ref lineNodeK, false);
        //            LineNodeEx lineNodeKOther = null;
        //            if (lineNodeK.OrtherIndexID > -1 && lineNodeK.OrtherIndexID < dataTableTemp.Rows.Count)
        //            {
        //                lineNodeKOther = new LineNodeEx();
        //                //lineNodeTemp = lineNodeKOther as LineNode;
        //                pLineNodeExTableTemp.GetLineNodeByDataRow(dataTableTemp.Rows[lineNodeK.OrtherIndexID], ref lineNodeKOther, false);
        //            }
        //            else
        //                lineNodeKOther = null;
        //            //不仅仅是最后一个
        //            if ((lineNodeBeginOther != null && lineNodeKOther != null && lineNodeBeginOther.PolygonID == lineNodeKOther.PolygonID)
        //                || (lineNodeBeginOther == null && lineNodeKOther == null && lineNodeBegin.IsFromLine == false && lineNodeK.IsFromLine == false))
        //            {
        //                //合并线
        //                lineNodeK.EntityID = lineNodeBegin.EntityID;
        //                pLineNodeExTable.SetLineNodeEntityID(dataTable.Rows[k - 1], lineNodeBegin.EntityID);
        //                if (lineNodeK.IsReverse != lineNodeBegin.IsReverse)
        //                {
        //                    //若方向不一致
        //                    //lineNodeK.Reverse();
        //                    pLineNodeExTable.ReverseLineNode(dataTable.Rows[k - 1]);
        //                    //在另一个面中的对象也反向
        //                    //if (lineNodeKOther != null)
        //                    //    lineNodeKOther.Reverse();
        //                    if (lineNodeKOther != null)
        //                        pLineNodeExTableTemp.ReverseLineNode(dataTableTemp.Rows[lineNodeK.OrtherIndexID]);
        //                }
        //                k--;
        //            }
        //            else
        //                bNeedFind = false;
        //        }
        //        lineNodeBegin = null;
        //    }
        //}
        /// <summary>
        /// 合并线节点标识码(非引用线)
        /// </summary>
        public void MergeLineEntityID(ref int nNewEntityID)
        {
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                MatchLineNodeExView matchLineNodeView = new MatchLineNodeExView(m_pOleDbConnection);
                ModifyEntityIDTable modifyEntityIDTable = new ModifyEntityIDTable(m_pOleDbConnection, true, this.IsFirst);
                ReverseLineNodeTable reverseLineNodeTable = new ReverseLineNodeTable(m_pOleDbConnection, true, this.IsFirst);

                DataTable dataViewLineNodeEx = matchLineNodeView.GetRecords("", "", "");

                bool bNeedSave = false;
                MatchLineNodeEx matchLineNodeUp = null;
                MatchLineNodeEx matchLineNode = null;
                MatchLineNodeEx matchLineBegin = null;
                int n = 0;
                bool bExistUp = false;
                List<MatchLineNodeEx> arrMatchLineNode = new List<MatchLineNodeEx>();
                List<int> arrLineNodeReverse = new List<int>();//记录已经反向的线节点
                while (dataViewLineNodeEx.Rows.Count > 0)
                {
                    for (int i = 0; i < dataViewLineNodeEx.Rows.Count; i++)
                    {
                        matchLineNode = new MatchLineNodeEx();
                        matchLineNodeView.GetLineByDataRow(dataViewLineNodeEx.Rows[i], ref matchLineNode);

                        //if (arrLineNodeReverse.Contains(matchLineNode.LineNodeID))
                        //    matchLineNode.IsReverse = -matchLineNode.IsReverse;

                        if (matchLineNodeUp != null)
                        {
                            //判断当前线节点与上一线节点是否属于同一个面
                            if (matchLineNode.PolygonID == matchLineNodeUp.PolygonID)
                            {
                                //属于同一个面
                                if (bExistUp == true)
                                {
                                    if (matchLineNode.EntityID == 0)//合并处理必须在同一个环内处理
                                    {
                                        //处理环内的首尾节点
                                        //MergePolygonLineEntityID(pLineNodeExTable, ref lineNodeBegin, lineNodeBeginOther, nIndexBegin, i, dataTable, dataTableTemp, pLineNodeExTableTemp);
                                        for (int j = 0; j < arrMatchLineNode.Count; j++)
                                        {
                                            modifyEntityIDTable.AddRow(arrMatchLineNode[j].LineNodeID, matchLineBegin.EntityID);

                                            if (arrMatchLineNode[j].IsReverse != matchLineBegin.IsReverse)
                                            {
                                                //若方向不一致

                                                //在另一个面中的对象也反向
                                                if (arrMatchLineNode[j].OtherLineNodeID != -1)
                                                {
                                                    if (arrMatchLineNode[j].OtherLineNodeID > arrMatchLineNode[j].LineNodeID)
                                                    {
                                                        //arrMatchLineNode[j].IsReverse = -arrMatchLineNode[j].IsReverse;
                                                        reverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                                                        reverseLineNodeTable.AddRow(arrMatchLineNode[j].OtherLineNodeID);
                                                    }
                                                }
                                                else
                                                {
                                                    //arrMatchLineNode[j].IsReverse = -arrMatchLineNode[j].IsReverse;
                                                    reverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                                                }
                                            }
                                            n++;
                                        }
                                        arrMatchLineNode.Clear();

                                        bExistUp = false;
                                    }
                                    else if (matchLineNode.LineIndex - matchLineNodeUp.LineIndex != 1)//(matchLineNode.IsFromLine == "1")//当前线节点是引用线
                                    {
                                        arrMatchLineNode.Clear();
                                        bExistUp = false;
                                    }
                                    else
                                    {
                                        //相邻线节点处理

                                        //线所属的面必须一致
                                        if ((matchLineNode.OtherLineNodeID != -1 && matchLineNodeUp.OtherLineNodeID != -1 && matchLineNode.OtherPolygonID == matchLineNodeUp.OtherPolygonID)
                                            || (matchLineNode.OtherLineNodeID == -1 && matchLineNodeUp.OtherLineNodeID == -1))
                                        {
                                            //合并线
                                            matchLineNode.EntityID = matchLineNodeUp.EntityID;
                                            modifyEntityIDTable.AddRow(matchLineNode.LineNodeID, matchLineNodeUp.EntityID);

                                            if (matchLineNode.IsReverse != matchLineNodeUp.IsReverse)
                                            {
                                                //若方向不一致

                                                //在另一个面中的对象也反向
                                                if (matchLineNode.OtherLineNodeID != -1)
                                                {
                                                    if (matchLineNode.OtherLineNodeID > matchLineNode.LineNodeID)
                                                    {
                                                        matchLineNode.IsReverse = -matchLineNode.IsReverse;
                                                        reverseLineNodeTable.AddRow(matchLineNode.LineNodeID);
                                                        reverseLineNodeTable.AddRow(matchLineNode.OtherLineNodeID);
                                                    }
                                                }
                                                else
                                                {
                                                    matchLineNode.IsReverse = -matchLineNode.IsReverse;
                                                    reverseLineNodeTable.AddRow(matchLineNode.LineNodeID);
                                                }

                                            }
                                            n++;
                                        }
                                        else
                                        {
                                            if (arrMatchLineNode.Count > 0)
                                                arrMatchLineNode.Clear();
                                        }

                                        if (matchLineNode.EntityID != matchLineBegin.EntityID)
                                        {
                                            if ((matchLineNode.OtherLineNodeID != -1 && matchLineBegin.OtherLineNodeID != -1 && matchLineNode.OtherPolygonID == matchLineBegin.OtherPolygonID)
                                                || (matchLineNode.OtherLineNodeID == -1 && matchLineBegin.OtherLineNodeID == -1))
                                            {
                                                arrMatchLineNode.Add(matchLineNode);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    arrMatchLineNode.Clear();
                                    matchLineBegin = matchLineNode;
                                    bExistUp = true;
                                }
                            }
                            else
                            {
                                //不属于同一个面(处理首尾节点)
                                //MergePolygonLineEntityID(pLineNodeExTable, ref lineNodeBegin, lineNodeBeginOther, nIndexBegin, i, dataTable, dataTableTemp, pLineNodeExTableTemp);
                                for (int j = 0; j < arrMatchLineNode.Count; j++)
                                {
                                    modifyEntityIDTable.AddRow(arrMatchLineNode[j].LineNodeID, matchLineBegin.EntityID);

                                    if (arrMatchLineNode[j].IsReverse != matchLineBegin.IsReverse)
                                    {
                                        //若方向不一致

                                        //在另一个面中的对象也反向
                                        if (arrMatchLineNode[j].OtherLineNodeID != -1)
                                        {
                                            if (arrMatchLineNode[j].OtherLineNodeID > arrMatchLineNode[j].LineNodeID)
                                            {
                                                //arrMatchLineNode[j].IsReverse = -arrMatchLineNode[j].IsReverse;
                                                reverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                                                reverseLineNodeTable.AddRow(arrMatchLineNode[j].OtherLineNodeID);
                                            }
                                        }
                                        else
                                        {
                                            //arrMatchLineNode[j].IsReverse = -arrMatchLineNode[j].IsReverse;
                                            reverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                                        }
                                    }
                                    n++;
                                }
                                arrMatchLineNode.Clear();
                                matchLineBegin = matchLineNode;
                                bExistUp = true;
                            }

                        }
                        else
                        {
                            matchLineBegin = matchLineNode;
                            bExistUp = true;
                        }

                        if (matchLineNode.EntityID == -1)
                        {
                            matchLineNode.EntityID = nNewEntityID++;
                            modifyEntityIDTable.AddRow(matchLineNode.LineNodeID, matchLineNode.EntityID);
                        }

                        matchLineNodeUp = matchLineNode;
                    }
                    if (n > modifyEntityIDTable.MaxRecordCount)
                    {
                        modifyEntityIDTable.Save(true);
                        reverseLineNodeTable.Save(true);
                        bNeedSave = true;
                        n = 0;
                    }

                    if (dataViewLineNodeEx.Rows.Count < matchLineNodeView.MaxRecordCount)
                        break;
                    dataViewLineNodeEx = matchLineNodeView.GetNextRecords();
                }

                //MergePolygonLineEntityID(pLineNodeExTable, ref lineNodeBegin, lineNodeBeginOther, nIndexBegin, dataTable.Rows.Count, dataTable, dataTableTemp, pLineNodeExTableTemp);
                for (int j = 0; j < arrMatchLineNode.Count; j++)
                {
                    modifyEntityIDTable.AddRow(arrMatchLineNode[j].LineNodeID, matchLineBegin.EntityID);

                    if (arrMatchLineNode[j].IsReverse != matchLineBegin.IsReverse)
                    {
                        //若方向不一致

                        //在另一个面中的对象也反向
                        if (arrMatchLineNode[j].OtherLineNodeID != -1)
                        {
                            if (arrMatchLineNode[j].OtherLineNodeID > arrMatchLineNode[j].LineNodeID)
                            {
                                //arrMatchLineNode[j].IsReverse = -arrMatchLineNode[j].IsReverse;
                                reverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                                reverseLineNodeTable.AddRow(arrMatchLineNode[j].OtherLineNodeID);
                            }
                        }
                        else
                        {
                            //arrMatchLineNode[j].IsReverse = -arrMatchLineNode[j].IsReverse;
                            reverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                        }
                    }

                }
                arrMatchLineNode.Clear();

                if (n > 0)
                {
                    modifyEntityIDTable.Save(true);
                    reverseLineNodeTable.Save(true);
                    bNeedSave = true;
                }
                if (bNeedSave == true)
                {
                    //删除冗余记录
                    modifyEntityIDTable.DeleteSurplusRows();
                    reverseLineNodeTable.DeleteSurplusRows();

                    //更新标识码
                    string strCommand = "";
                    strCommand = "Update LineNodeEx,ModifyEntityID Set LineNodeEx.EntityID=ModifyEntityID.EntityID Where LineNodeEx.LineNodeID=ModifyEntityID.LineNodeID";
                    modifyEntityIDTable.ExecuteNonQuery(strCommand);

                    //更新反向标识
                    strCommand = "Update LineNodeEx Set IsReverse=-IsReverse Where LineNodeID In ( Select LineNodeID From ReverseLineNode )";//反向
                    reverseLineNodeTable.ExecuteNonQuery(strCommand);
                }
            }

            /*
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection, false);

                string strLineNodeExOrderBy = pLineNodeExTable.FieldName_PolygonID + "," + pLineNodeExTable.FieldName_LineIndex;
                DataTable dataTable = pLineNodeExTable.GetRecords("", "", strLineNodeExOrderBy);

                string strLineNodeExOrderByTemp = pLineNodeExTable.FileName_LineNodeID;
                LineNodeExTable pLineNodeExTableTemp = new LineNodeExTable(m_pOleDbConnection, false);
                DataTable dataTableTemp = pLineNodeExTableTemp.GetRecords("", "", strLineNodeExOrderByTemp);

                LineNodeEx lineNodeUp = null;
                LineNodeEx lineNodeUpOther = null;
                LineNodeEx lineNodeCurrent = null;
                LineNodeEx lineNodeCurrentOther = null;
                LineNodeEx lineNodeBegin = null;
                LineNodeEx lineNodeBeginOther = null;
                bool bExistUp = false;
                int nIndexBegin = -1;

                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    //获取当前线节点
                    lineNodeCurrent = new LineNodeEx();
                    //LineNode lineNodeTemp = lineNodeCurrent as LineNode;
                    pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[i], ref lineNodeCurrent, false);
                    if (lineNodeCurrent.OrtherIndexID > -1 && lineNodeCurrent.OrtherIndexID < dataTableTemp.Rows.Count)
                    {
                        lineNodeCurrentOther = new LineNodeEx();
                        //lineNodeTemp = lineNodeCurrentOther as LineNode;
                        pLineNodeExTableTemp.GetLineNodeByDataRow(dataTableTemp.Rows[lineNodeCurrent.OrtherIndexID], ref lineNodeCurrentOther, false);
                    }
                    else
                        lineNodeCurrentOther = null;

                    if (lineNodeBegin == null)
                    {
                        lineNodeBegin = lineNodeCurrent;
                        lineNodeBeginOther = lineNodeCurrentOther;
                        nIndexBegin = i;
                    }

                    if (i > 0)
                    {
                        //判断当前线节点与上一线节点是否属于同一个面
                        if (lineNodeCurrent.PolygonID == lineNodeUp.PolygonID)
                        {
                            //属于同一个面
                            if (bExistUp == true)
                            {
                                if (lineNodeCurrent.EntityID == 0)//合并处理必须在同一个环内处理
                                {
                                    //处理环内的首尾节点
                                    MergePolygonLineEntityID(pLineNodeExTable, ref lineNodeBegin, lineNodeBeginOther, nIndexBegin, i, dataTable, dataTableTemp, pLineNodeExTableTemp);

                                    bExistUp = false;
                                }
                                else if (lineNodeCurrent.IsFromLine == true)//当前线节点是引用线
                                {
                                    bExistUp = false;
                                }
                                else
                                {
                                    //相邻线节点处理

                                    //线所属的面必须一致
                                    if ((lineNodeCurrentOther != null && lineNodeUpOther != null && lineNodeCurrentOther.PolygonID == lineNodeUpOther.PolygonID)
                                        || (lineNodeCurrentOther == null && lineNodeUpOther == null && lineNodeCurrent.IsFromLine == false && lineNodeUp.IsFromLine == false))
                                    {
                                        //合并线
                                        lineNodeCurrent.EntityID = lineNodeUp.EntityID;
                                        pLineNodeExTable.SetLineNodeEntityID(dataTable.Rows[i], lineNodeUp.EntityID);

                                        if (lineNodeCurrent.IsReverse != lineNodeUp.IsReverse)
                                        {
                                            //若方向不一致
                                            //lineNodeCurrent.Reverse();
                                            pLineNodeExTable.ReverseLineNode(dataTable.Rows[i]);
                                            //在另一个面中的对象也反向
                                            //if (lineNodeCurrent.OtherPolygonLineNode != null)
                                            //    lineNodeCurrent.OtherPolygonLineNode.Reverse();
                                            if (lineNodeCurrentOther != null)
                                                pLineNodeExTableTemp.ReverseLineNode(dataTableTemp.Rows[lineNodeCurrent.OrtherIndexID]);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                bExistUp = true;
                            }

                        }
                        else
                        {
                            //不属于同一个面(处理首尾节点)
                            MergePolygonLineEntityID(pLineNodeExTable, ref lineNodeBegin, lineNodeBeginOther, nIndexBegin, i, dataTable, dataTableTemp, pLineNodeExTableTemp);

                            lineNodeBegin = lineNodeCurrent;
                            lineNodeBeginOther = lineNodeCurrentOther;
                            nIndexBegin = i;
                            bExistUp = true;
                        }
                    }
                    lineNodeUp = lineNodeCurrent;
                    lineNodeUpOther = lineNodeCurrentOther;

                    if ((i + 1) % 10000 == 0)
                    {
                        pLineNodeExTable.Save(false);
                        pLineNodeExTableTemp.Save(false);
                    }
                }

                MergePolygonLineEntityID(pLineNodeExTable, ref lineNodeBegin, lineNodeBeginOther, nIndexBegin, dataTable.Rows.Count, dataTable, dataTableTemp, pLineNodeExTableTemp);

                pLineNodeExTable.Save(true);
                pLineNodeExTableTemp.Save(true);
            }
             * */
        }
예제 #3
0
파일: TempFile.cs 프로젝트: hy1314200/HyDM
        ///// <summary>
        ///// 处理线段在一个面中连续,另一个面中不连续的情况
        ///// </summary>
        //public void SplitPolygonLineNode(LineNodeExTable pLineNodeExTable,List<int> arrSplitEntityID, int nBeginPolygonIndex, int nEndPolygonIndex,
        //    DataTable dataTable, DataTable dataTableTemp, LineNodeExTable pLineNodeExTableTemp)
        //{
        //    LineNodeEx lineNodeK = null;
        //    LineNodeEx lineNodeKOther = null;
        //    //LineNode lineNodeTemp = null;
        //    for (int j = 0; j < arrSplitEntityID.Count; j++)
        //    {
        //        for (int k = nBeginPolygonIndex; k < nEndPolygonIndex; k++)
        //        {
        //            lineNodeK = new LineNodeEx();
        //            //lineNodeTemp = lineNodeK as LineNode;
        //            pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[k], ref lineNodeK, false);
        //            if (lineNodeK.OrtherIndexID > -1 && lineNodeK.OrtherIndexID < dataTableTemp.Rows.Count)
        //            {
        //                lineNodeKOther = new LineNodeEx();
        //                //lineNodeTemp = lineNodeKOther as LineNode;
        //                pLineNodeExTableTemp.GetLineNodeByDataRow(dataTableTemp.Rows[lineNodeK.OrtherIndexID], ref lineNodeKOther, false);
        //            }
        //            else
        //                lineNodeKOther = null;
        //            if (lineNodeKOther != null)
        //            {
        //                if (arrSplitEntityID[j] == lineNodeKOther.EntityID)
        //                {
        //                    if (lineNodeKOther.IsReverse == false)
        //                    {
        //                        //lineNodeKOther.Reverse();
        //                        pLineNodeExTableTemp.ReverseLineNode(dataTableTemp.Rows[lineNodeK.OrtherIndexID]);
        //                        //lineNodeK.Reverse();
        //                        pLineNodeExTable.ReverseLineNode(dataTable.Rows[k]);
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}
        /// <summary>
        /// 处理线段在一个面中连续,另一个面中不连续的情况
        /// </summary>
        public void SplitLineNode()
        {
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                ReverseLineNodeTable pReverseLineNodeTable = new ReverseLineNodeTable(m_pOleDbConnection, true, false);

                MatchLineNodeExView pMatchLineNodeView = new MatchLineNodeExView(m_pOleDbConnection);
                DataTable dataViewLineNodeEx = pMatchLineNodeView.GetRecords("", "", "");

                MatchLineNodeEx matchLineNodeUp = null;
                MatchLineNodeEx matchLineNode = null;

                List<MatchLineNodeEx> arrMatchLineNode = new List<MatchLineNodeEx>();
                List<int> arrAllEntityID = new List<int>();
                List<int> arrSplitEntityID = new List<int>();
                int nReverseCount = 0;
                bool bNeedSave = false;
                while (dataViewLineNodeEx.Rows.Count > 0)
                {
                    for (int i = 0; i < dataViewLineNodeEx.Rows.Count; i++)
                    {
                        matchLineNode = new MatchLineNodeEx();
                        pMatchLineNodeView.GetLineByDataRow(dataViewLineNodeEx.Rows[i], ref matchLineNode);

                        if (matchLineNode.OtherEntityID > 0 && matchLineNode.IsReverse == -1)
                        {
                            arrMatchLineNode.Add(matchLineNode);
                        }

                        if (matchLineNodeUp != null)
                        {
                            //判断当前线节点与上一线节点是否属于同一个面
                            if (matchLineNode.PolygonID != matchLineNodeUp.PolygonID)
                            {
                                if (arrSplitEntityID.Count > 0)
                                {
                                    for (int j = 0; j < arrMatchLineNode.Count; j++)
                                    {
                                        if (arrSplitEntityID.Contains(matchLineNode.EntityID) == true)
                                        {
                                            pReverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                                            pReverseLineNodeTable.AddRow(arrMatchLineNode[j].OtherLineNodeID);
                                            nReverseCount++;
                                        }
                                    }
                                }
                                arrMatchLineNode.Clear();
                                arrAllEntityID.Clear();
                                arrSplitEntityID.Clear();
                            }
                            else
                            {
                                if (matchLineNode.OtherEntityID != matchLineNodeUp.OtherEntityID)
                                {
                                    if (matchLineNode.OtherEntityID > 0 && matchLineNode.IsReverse == -1)
                                    {
                                        if (arrAllEntityID.Contains(matchLineNode.OtherEntityID) == false)
                                        {
                                            arrAllEntityID.Add(matchLineNode.OtherEntityID);
                                        }
                                        else
                                        {
                                            arrSplitEntityID.Add(matchLineNode.OtherEntityID);
                                        }
                                    }
                                }
                            }
                        }

                        if (arrAllEntityID.Count == 0)
                            arrAllEntityID.Add(matchLineNode.OtherEntityID);

                        matchLineNodeUp = matchLineNode;
                    }
                    if (nReverseCount > pReverseLineNodeTable.MaxRecordCount)
                    {
                        pReverseLineNodeTable.Save(true);
                        nReverseCount = 0;
                        bNeedSave = true;
                    }

                    if (dataViewLineNodeEx.Rows.Count < pMatchLineNodeView.MaxRecordCount)
                        break;
                    dataViewLineNodeEx = pMatchLineNodeView.GetNextRecords();
                }

                if (arrSplitEntityID.Count > 0)
                {
                    for (int j = 0; j < arrMatchLineNode.Count; j++)
                    {
                        if (arrSplitEntityID.Contains(matchLineNode.EntityID) == true)
                        {
                            pReverseLineNodeTable.AddRow(arrMatchLineNode[j].LineNodeID);
                            pReverseLineNodeTable.AddRow(arrMatchLineNode[j].OtherLineNodeID);
                            nReverseCount++;
                        }
                    }
                }
                arrMatchLineNode.Clear();
                arrAllEntityID.Clear();
                arrSplitEntityID.Clear();

                if (nReverseCount > 0)
                {
                    pReverseLineNodeTable.Save(true);
                    bNeedSave = true;
                }

                if (bNeedSave == true)
                {
                    //删除冗余记录
                    pReverseLineNodeTable.DeleteSurplusRows();

                    //更新反向标识
                    string strCommand = "Update LineNodeEx Set IsReverse=0-IsReverse Where LineNodeID In ( Select LineNodeID From ReverseLineNode )";//反向
                    pReverseLineNodeTable.ExecuteNonQuery(strCommand);
                }
                //LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection, false);

                //string strLineNodeExOrderBy = pLineNodeExTable.FieldName_PolygonID + "," + pLineNodeExTable.FieldName_LineIndex;
                //DataTable dataTable = pLineNodeExTable.GetRecords("", "", strLineNodeExOrderBy);

            //    //string strLineNodeExOrderByTemp = pLineNodeExTable.FileName_LineNodeID;
            //    //LineNodeExTable pLineNodeExTableTemp = new LineNodeExTable(m_pOleDbConnection, false);
            //    //DataTable dataTableTemp = pLineNodeExTableTemp.GetRecords("", "", strLineNodeExOrderByTemp);

            //    LineNodeEx lineNodeUp = null;
            //    //LineNodeEx lineNodeUpOther = null;
            //    LineNodeEx lineNodeCurrent = null;
            //    //LineNodeEx lineNodeCurrentOther = null;

            //    List<int> arrAllEntityID = new List<int>();
            //    List<int> arrSplitEntityID = new List<int>();
            //    int nBeginPolygonIndex = 0;
            //    for (int i = 0; i < dataTable.Rows.Count; i++)
            //    {
            //        lineNodeCurrent = new LineNodeEx();
            //        pLineNodeExTable.GetLineNodeByDataRow(dataTable.Rows[i], ref lineNodeCurrent, false);
            //        //if (lineNodeCurrent.OrtherIndexID > -1 && lineNodeCurrent.OrtherIndexID < dataTableTemp.Rows.Count)
            //        //{
            //        //    lineNodeCurrentOther = new LineNodeEx();
            //        //    pLineNodeExTableTemp.GetLineNodeByDataRow(dataTableTemp.Rows[lineNodeCurrent.OrtherIndexID], ref lineNodeCurrentOther, false);
            //        //}
            //        //else
            //        //    lineNodeCurrentOther = null;

            //        if (i == 0)
            //        {
            //            //if(lineNodeCurrent.OrtherIndexID!=-1)
            //            //arrAllEntityID.Add(lineNodeCurrentOther.EntityID);
            //        }

            //        if (i > 0)
            //        {
            //            //判断当前线节点与上一线节点是否属于同一个面
            //            if (lineNodeCurrent.PolygonID != lineNodeUp.PolygonID)
            //            {
            //                SplitPolygonLineNode(pLineNodeExTable, arrSplitEntityID, nBeginPolygonIndex, i, dataTable, dataTableTemp, pLineNodeExTableTemp);

            //                nBeginPolygonIndex = i;
            //                arrAllEntityID.Clear();
            //                arrSplitEntityID.Clear();
            //            }
            //            else
            //            {
            //                if (lineNodeCurrent.OrtherIndexID != -1)
            //                {

            //                    if (lineNodeUp.OrtherIndexID == -1 ||
            //                        lineNodeCurrentOther.EntityID != lineNodeUpOther.EntityID)
            //                    {
            //                        if (arrAllEntityID.Contains(lineNodeCurrentOther.EntityID) == false)
            //                        {
            //                            arrAllEntityID.Add(lineNodeCurrentOther.EntityID);
            //                        }
            //                        else
            //                        {
            //                            arrSplitEntityID.Add(lineNodeCurrentOther.EntityID);
            //                        }
            //                    }
            //                }

            //            }
            //        }

            //        if ((i + 1) % 10000 == 0)
            //        {
            //            pLineNodeExTable.Save(false);
            //            pLineNodeExTableTemp.Save(false);
            //        }

            //        lineNodeUp = lineNodeCurrent;
            //        //lineNodeUpOther = lineNodeCurrentOther;
            //    }

            //    SplitPolygonLineNode(pLineNodeExTable, arrSplitEntityID, nBeginPolygonIndex, dataTable.Rows.Count, dataTable, dataTableTemp, pLineNodeExTableTemp);

            //    pLineNodeExTable.Save(true);
            //    pLineNodeExTableTemp.Save(true);
            }
        }