Exemplo n.º 1
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);
                 * */
            }
        }
Exemplo n.º 2
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);
                //}
            }
        }
Exemplo n.º 3
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();

                }

            }
        }
Exemplo n.º 4
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);

            }
        }
Exemplo n.º 5
0
        //public void UpdatePolygonRing(LineNodeExTable pLineNodeExTable, int nIndexBegin, int nIndexEnd, int nCount, DataTable dataTable)
        //{
        //    if (nCount - nIndexEnd > 1 && nIndexBegin != nIndexEnd)
        //    {
        //        for (int j = nCount - 1; j >= nIndexBegin; j--)
        //        {
        //            if (j > nIndexEnd)
        //            {
        //                pLineNodeExTable.SetLineIndexChange(dataTable.Rows[j], -(nIndexEnd - nIndexBegin + 1));
        //            }
        //            else
        //            {
        //                pLineNodeExTable.SetLineIndexChange(dataTable.Rows[j], nCount - 1 - nIndexEnd);
        //            }
        //        }
        //    }
        //}
        /// <summary>
        /// 处理环内同一边界线分布在环的首尾的情况
        /// </summary>
        public void UpdateRing()
        {
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                //ModifyLineIndexTable pModifyLineIndexTable = new ModifyLineIndexTable(m_pOleDbConnection, true);
                //pModifyLineIndexTable.IsFirst = this.IsFirst;

                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection);

                //LineNodeEx lineNodeBegin = null;//环的开始线节点
                int nLineNodeIDBegin = -1;
                int nEntityIDBegin = -1;
                //int nIndexBegin = -1;
                //bool bNeedSave = false;
                //bool bNeedMove = false;//是否需要处理
                int nIndexEnd = -1;    //环的结束索引(该索引以后的节点都要移到环的开始位置

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

                //LineNodeEx lineNodeUp = null;
                //LineNodeEx lineNodeCurrent = null;
                int nPolygonID = -1;
                int nLineNodeID = -1;
                int nEntityID = -1;
                int nPolygonIDUp = -1;
                int nLineNodeIDUp = -1;
                int nEntityIDUp = -1;

                List<string> arrWhere = new List<string>();
                List<string> arrValue = new List<string>();
                //List<LineNodeEx> arrLineNodeEx = new List<LineNodeEx>();
                int nLineNodeExCount = 0;
                //int n = 0;
                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);
                        nPolygonID = Convert.ToInt32(dataTable.Rows[i][0]);
                        nEntityID = Convert.ToInt32(dataTable.Rows[i][1]);
                        nLineNodeID = Convert.ToInt32(dataTable.Rows[i][2]);

                        if (nLineNodeIDBegin == -1)
                        {
                            nLineNodeIDBegin = nLineNodeID;
                            nEntityIDBegin = nEntityID;
                            //lineNodeBegin = lineNodeCurrent;
                            //nIndexBegin = 0;
                            nIndexEnd = 0;
                        }

                        if (nLineNodeIDUp != -1)
                        {
                            //判断当前线节点与上一线节点是否属于同一个面
                            if (nPolygonID == nPolygonIDUp)
                            {
                                if (nEntityID == 0)
                                {
                                    UpdatePolygonRing(ref nLineNodeExCount, nLineNodeIDBegin, nIndexEnd, ref arrWhere, ref arrValue);
                                    //UpdatePolygonRing(ref arrLineNodeEx, nIndexEnd, pModifyLineIndexTable, ref n);
                                    //arrLineNodeEx.Clear();
                                    nLineNodeIDBegin = -1;
                                }
                                else if (nEntityID != nEntityIDBegin)
                                {
                                    nIndexEnd = nLineNodeExCount;// arrLineNodeEx.Count;
                                }
                            }
                            else
                            {
                                UpdatePolygonRing(ref nLineNodeExCount, nLineNodeIDBegin, nIndexEnd, ref arrWhere, ref arrValue);
                                //UpdatePolygonRing(ref arrLineNodeEx, nIndexEnd, pModifyLineIndexTable, ref n);
                                //arrLineNodeEx.Clear();

                                nLineNodeIDBegin = nLineNodeID;
                                nEntityIDBegin = nEntityID;
                                //nIndexBegin = 0;
                                nIndexEnd = 0;
                            }
                        }
                        if (nEntityID != 0)
                        {
                            //arrLineNodeEx.Add(lineNodeCurrent);
                            nLineNodeExCount++;
                        }

                        nPolygonIDUp = nPolygonID;
                        nLineNodeIDUp = nLineNodeID;
                        nEntityIDUp = nEntityID;
                    }

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

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

                }

                UpdatePolygonRing(ref nLineNodeExCount, nLineNodeIDBegin, nIndexEnd, ref arrWhere, ref arrValue);
                //UpdatePolygonRing(ref arrLineNodeEx, nIndexEnd, pModifyLineIndexTable, ref n);

                //if (n > 0)
                //{
                //    pModifyLineIndexTable.Save(true);
                //    bNeedSave = true;
                //}

                //更新线节点在面实体中的顺序号
                //if (bNeedSave == true)
                //{
                //    string strCommand = "Update LineNodeEx,ModifyLineIndex Set LineNodeEx.LineIndex=ModifyLineIndex.LineIndex Where LineNodeEx.LineNodeID=ModifyLineIndex.LineNodeID";
                //    pModifyLineIndexTable.ExecuteNonQuery(strCommand);
                //}
                string strCommand = "";
                for (int i = 0; i < arrWhere.Count; i++)
                {
                    strCommand = "Update LineNodeEx Set LineIndex=" + arrValue[i] + " Where " + arrWhere[i];
                    pLineNodeExTable.ExecuteNonQuery(strCommand);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新已反向的线节点的标识码(非引用线)
        /// </summary>
        public void UpdateReverseLineEntityID()
        {
            /*
             *  Update LineNodeEx a,LineNodeEx b Set a.EntityID=b.EntityID Where a.IsReverse='1' and b.OrtherIndexID=a.LineNodeID
             * */
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection);
                string strCommand = "Update LineNodeEx a,LineNodeEx b Set a.EntityID=b.EntityID Where a.IsReverse=1 and b.OrtherLineNodeID=a.LineNodeID";// and a.OrtherLineNodeID=b.LineNodeID
                pLineNodeExTable.ExecuteNonQuery(strCommand);

                //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 lineNodeCurrent = null;
                //LineNodeEx lineNodeCurrentOther = null;

                //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 (lineNodeCurrent.IsReverse)
                //    {
                //        if (lineNodeCurrentOther != null)
                //        {
                //            pLineNodeExTable.SetLineNodeEntityID(dataTable.Rows[i], lineNodeCurrentOther.EntityID);
                //        }
                //    }

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

                //pLineNodeExTable.Save(true);
            }
        }
Exemplo n.º 7
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);
                }
            }
        }