Exemple #1
0
        /// <summary>
        /// 写入多边形线节点(非引用线图层)
        /// </summary>
        /// <param name="pVCTFile">VCT文件对象</param>
        public void WritePolygonLineNodes(VCTFile pVCTFile)
        {
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection);

                //只写入正向线节点
                string strWhere = pLineNodeExTable.FieldName_IsFromLine + "=-1 And "
                    + pLineNodeExTable.FieldName_IsReverse + "=-1 And " + pLineNodeExTable.FieldName_EntityID + "<>0";
                //按标识码、在面的边界线集合中的索引排序
                string strLineNodeExOrderBy = pLineNodeExTable.FieldName_PolygonID + "," + pLineNodeExTable.FieldName_LineIndex;
                DataTable dataTable = pLineNodeExTable.GetRecords(strWhere, "", strLineNodeExOrderBy);

                LineNodeEx lineNode = null;
                LineNodeEx lineNodeCurrent = null;
                LineNodeEx lineNodeUp = null;

                //for (int i = 0; i < dataTable.Rows.Count; i++)
                while (dataTable.Rows.Count > 0)
                {
                    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 (lineNode == null)
                        {
                            lineNode = lineNodeCurrent;
                        }
                        else
                        {
                            //判断当前线节点与上一线节点是否属于同一个面
                            if (lineNodeCurrent.PolygonID != lineNodeUp.PolygonID)
                            {
                                pVCTFile.WritePolygonLineNode(lineNode);
                                lineNode = lineNodeCurrent;
                            }
                            else
                            {
                                if (lineNodeCurrent.EntityID == lineNode.EntityID)
                                {
                                    lineNode.SegmentNodes.AddRange(lineNodeCurrent.SegmentNodes);
                                }
                                else
                                {
                                    pVCTFile.WritePolygonLineNode(lineNode);
                                    lineNode = lineNodeCurrent;
                                }
                            }
                        }
                        lineNodeUp = lineNodeCurrent;
                    }

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

                }
                if (lineNode != null)
                    pVCTFile.WritePolygonLineNode(lineNode);

            }
        }
Exemple #2
0
        /// <summary>
        /// 处理面图层中构面线与线图层(与面图层关联)中的线对象之间的关系
        /// </summary>
        public void MatchPolygonToLine()
        {
            /*          string strCommand ="";
                      strCommand = "Update LineNodeEx,LineNode Set LineNodeEx.EntityID=LineNode.EntityID,LineNodeEx.IsFromLine='1' Where"
                      +" (LineNodeEx.X1-LineNode.X1)<0.000001 and (LineNodeEx.X1-LineNode.X1)>-0.000001 "
                      +"and (LineNodeEx.Y1-LineNode.Y1)<0.000001 and (LineNodeEx.Y1-LineNode.Y1)>-0.000001  "
                      +"and (LineNodeEx.X2-LineNode.X2)<0.000001 and (LineNodeEx.X2-LineNode.X2)>-0.000001  "
                      +"and (LineNodeEx.Y2-LineNode.Y2)<0.000001 and (LineNodeEx.Y2-LineNode.Y2)>-0.000001 and LineNodeEx.EntityID=-1";
                      pLineNodeExTable.ExecuteNonQuery(strCommand);

                      strCommand = "Update LineNodeEx,LineNode Set LineNodeEx.EntityID=LineNode.EntityID,LineNodeEx.IsFromLine='1' Where"
                       + "(LineNodeEx.X2-LineNode.X1)<0.000001 and (LineNodeEx.X2-LineNode.X1)>-0.000001 "
                      + "and (LineNodeEx.Y2-LineNode.Y1)<0.000001 and (LineNodeEx.Y2-LineNode.Y1)>-0.000001  "
                      + "and (LineNodeEx.X1-LineNode.X2)<0.000001 and (LineNodeEx.X1-LineNode.X2)>-0.000001  "
                      + "and (LineNodeEx.Y1-LineNode.Y2)<0.000001 and (LineNodeEx.Y1-LineNode.Y2)>-0.000001 and LineNodeEx.EntityID=-1";

                      pLineNodeExTable.ExecuteNonQuery(strCommand);

              */

            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                LineNodeTable pLineNodeTable = new LineNodeTable(m_pOleDbConnection);
                //pLineNodeTable.MaxRecordCount = 500000;
                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection);
                //pLineNodeExTable.MaxRecordCount = 500000;
                MatchLineNodeTable pMatchLineNodeTable = new MatchLineNodeTable(m_pOleDbConnection, true, this.IsFirst);

                string strLineNodeExWhere = pLineNodeExTable.FieldName_EntityID + "=-1";
                string strLineNodeExOrderBy = pLineNodeExTable.FieldName_X1 + ","
                    + pLineNodeExTable.FieldName_Y1 + ","
                    + pLineNodeExTable.FieldName_X2 + ","
                    + pLineNodeExTable.FieldName_Y2 + ","
                    + pLineNodeExTable.FieldName_EntityID;
                string strLineNodeWhere = pLineNodeTable.FieldName_EntityID + ">0";
                string strLineNodeOrderBy = pLineNodeTable.FieldName_X1 + ","
                    + pLineNodeTable.FieldName_Y1 + ","
                    + pLineNodeTable.FieldName_X2 + ","
                    + pLineNodeTable.FieldName_Y2 + ","
                    + pLineNodeTable.FieldName_EntityID;

                DataTable dataTableLineNodeEx = pLineNodeExTable.GetRecords(strLineNodeExWhere, "", strLineNodeExOrderBy);
                DataTable dataTableLineNode = pLineNodeTable.GetRecords(strLineNodeWhere, "", strLineNodeOrderBy);

                if (dataTableLineNode.Rows.Count == 0 || dataTableLineNodeEx.Rows.Count == 0)
                    return;

                //更新构面线的标识码
                bool bNeedSave = false;
                int j = 0;
                int i = 0;
                int n = 0;
                while (dataTableLineNode.Rows.Count > 0)
                {
                    for (i = 0; i < dataTableLineNode.Rows.Count; i++)
                    {
                        if (j == dataTableLineNodeEx.Rows.Count)
                            break;

                        LineNodeSimple lineNode = new LineNodeSimple();
                        pLineNodeTable.GetLineNodeByDataRow(dataTableLineNode.Rows[i], ref lineNode, false);

                        while (dataTableLineNodeEx.Rows.Count > 0)
                        {
                            for (; j < dataTableLineNodeEx.Rows.Count; j++)
                            {
                                LineNodeSimple lineNodeEx = new LineNodeSimple();
                                pLineNodeExTable.GetLineNodeByDataRow(dataTableLineNodeEx.Rows[j], ref lineNodeEx, false);

                                if (lineNode == lineNodeEx)
                                {
                                    pMatchLineNodeTable.AddRow(lineNode.IndexID, lineNodeEx.IndexID, lineNode.EntityID);
                                    n++;
                                    //pLineNodeExTable.SetLineNodeFromLine(dataTableLineNodeEx.Rows[j], lineNode.EntityID, false);
                                    //if (bNeedSave == false)
                                    //    bNeedSave = true;
                                }
                                else if (lineNode > lineNodeEx)
                                {

                                }
                                else
                                {
                                    break;
                                }
                            }

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

                    if (n >= pMatchLineNodeTable.MaxRecordCount)
                    {
                        bNeedSave = true;
                        pMatchLineNodeTable.Save(true);
                        n = 0;
                    }

                    if (i == dataTableLineNode.Rows.Count)
                    {
                        if (dataTableLineNode.Rows.Count < pLineNodeTable.MaxRecordCount)
                            break;
                        dataTableLineNode = pLineNodeTable.GetNextRecords();
                    }
                    else
                        break;
                }
                if (n > 0)
                {
                    bNeedSave = true;
                    pMatchLineNodeTable.Save(true);
                    n = 0;
                }

                if (bNeedSave == true)
                {
                    string strCommand = "Update " + pLineNodeExTable.TableName_TempTable + "," + pMatchLineNodeTable.TableName_TempTable + " Set "
                        + pLineNodeExTable.TableName_TempTable + "." + pLineNodeExTable.FieldName_EntityID + "=" + pMatchLineNodeTable.TableName_TempTable+"." + pMatchLineNodeTable.FieldName_EntityID + ","
                        + pLineNodeExTable.FieldName_IsReverse + "=-1,"
                        + pLineNodeExTable.FieldName_IsFromLine + "=1"
                        + " Where " + pLineNodeExTable.TableName_TempTable + "." + pLineNodeExTable.FieldName_LineNodeID + "=" + pMatchLineNodeTable.TableName_TempTable + "." + pMatchLineNodeTable.FieldName_LineExIndexID;
                    pLineNodeExTable.ExecuteNonQuery(strCommand);

                    bNeedSave = false;
                    pMatchLineNodeTable = new MatchLineNodeTable(m_pOleDbConnection, true, false);
                }

                //反向
                strLineNodeExOrderBy = pLineNodeExTable.FieldName_X2 + ","
                    + pLineNodeExTable.FieldName_Y2 + ","
                    + pLineNodeExTable.FieldName_X1 + ","
                    + pLineNodeExTable.FieldName_Y1 + ","
                    + pLineNodeExTable.FieldName_EntityID;

                //必须是未找到标识码的
                strLineNodeExWhere = pLineNodeExTable.FieldName_EntityID + "=-1";
                dataTableLineNodeEx = pLineNodeExTable.GetRecords(strLineNodeExWhere, "", strLineNodeExOrderBy);
                dataTableLineNode = pLineNodeTable.GetRecords(strLineNodeWhere, "", strLineNodeOrderBy);

                j = 0;
                while (dataTableLineNode.Rows.Count > 0)
                {
                    for (i = 0; i < dataTableLineNode.Rows.Count; i++)
                    {
                        if (j == dataTableLineNodeEx.Rows.Count)
                            break;

                        LineNodeSimple lineNode = new LineNodeSimple();
                        pLineNodeTable.GetLineNodeByDataRow(dataTableLineNode.Rows[i], ref lineNode, false);
                        while (dataTableLineNodeEx.Rows.Count > 0)
                        {

                            for (; j < dataTableLineNodeEx.Rows.Count; j++)
                            {
                                LineNodeSimple lineNodeEx = new LineNodeSimple();
                                pLineNodeExTable.GetLineNodeByDataRow(dataTableLineNodeEx.Rows[j], ref lineNodeEx, true);

                                if (lineNodeEx.EntityID != -1)
                                    continue;

                                if (lineNode == lineNodeEx)
                                {
                                    pMatchLineNodeTable.AddRow(lineNode.IndexID, lineNodeEx.IndexID, lineNode.EntityID);
                                    n++;
                                    //pLineNodeExTable.SetLineNodeEntityID(dataTableLineNodeEx.Rows[j], lineNode.EntityID, true);
                                    //if (bNeedSave == false)
                                    //    bNeedSave = true;
                                }
                                else if (lineNode > lineNodeEx)
                                {

                                }
                                else
                                {
                                    break;
                                }

                            }

                            if (j == dataTableLineNodeEx.Rows.Count)
                            {
                                //if (bNeedSave == true)
                                //{
                                //    pLineNodeExTable.Save(false);
                                //}
                                if (dataTableLineNodeEx.Rows.Count < pLineNodeExTable.MaxRecordCount)
                                    break;
                                //else
                                //    bNeedSave = false;
                                dataTableLineNodeEx = pLineNodeExTable.GetNextRecords();
                                j = 0;
                            }
                            else
                                break;
                        }
                    }

                    if (n >= pMatchLineNodeTable.MaxRecordCount)
                    {
                        bNeedSave = true;
                        pMatchLineNodeTable.Save(true);
                        n = 0;
                    }

                    if (i == dataTableLineNode.Rows.Count)
                    {
                        if (dataTableLineNode.Rows.Count < pLineNodeTable.MaxRecordCount)
                            break;
                        dataTableLineNode = pLineNodeTable.GetNextRecords();
                    }
                    else
                        break;
                }
                if (n > 0)
                {
                    bNeedSave = true;
                    pMatchLineNodeTable.Save(true);
                }

                if (bNeedSave == true)
                {
                    string strCommand = "Update " + pLineNodeExTable.TableName_TempTable + "," + pMatchLineNodeTable.TableName_TempTable + " Set "
                        + pLineNodeExTable.TableName_TempTable + "." + pLineNodeExTable.FieldName_EntityID + "=" + pMatchLineNodeTable.TableName_TempTable + "." + pMatchLineNodeTable.FieldName_EntityID + ","
                        + pLineNodeExTable.FieldName_IsReverse + "=1,"
                        + pLineNodeExTable.FieldName_IsFromLine + "=1"
                        + " Where " + pLineNodeExTable.TableName_TempTable + "." + pLineNodeExTable.FieldName_LineNodeID + "=" + pMatchLineNodeTable.TableName_TempTable + "." + pMatchLineNodeTable.FieldName_LineExIndexID;
                    pLineNodeExTable.ExecuteNonQuery(strCommand);
                }
                /*
                 * 匹配条件不正确,FieldName_EntityID重复
                //更新成对索引
                strCommand = "Update " + pLineNodeExTable.TableName_TempTable + " As a," + pLineNodeExTable.TableName_TempTable + " As b Set a."
                    + pLineNodeExTable.FieldName_OrtherLineNodeID + "=b." + pLineNodeExTable.FieldName_LineNodeID
                    //+ ",b." + pLineNodeExTable.FieldName_OrtherLineNodeID + "=a." + pLineNodeExTable.FieldName_LineNodeID
                    + " Where a." + pLineNodeExTable.FieldName_EntityID + ">0 And a." + pLineNodeExTable.FieldName_EntityID + "=b." + pLineNodeExTable.FieldName_EntityID;
                pLineNodeExTable.ExecuteNonQuery(strCommand);
                 * */
            }
        }
Exemple #3
0
        //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);
                }
            }
        }