Exemple #1
0
 public virtual void GetLineByDataRow(DataRow dataRow, ref TempLineNode line)
 {
     if (dataRow != null)
     {
         line.LineNodeID = dataRow["LineID"] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow["LineID"]);
         line.X1 = dataRow["PX1"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PX1"]);
         line.Y1 = dataRow["PY1"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PY1"]);
         line.X2 = dataRow["PX2"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PX2"]);
         line.Y2 = dataRow["PY2"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PY2"]);
         line.IsReverse = dataRow[5] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow[5]);
     }
 }
Exemple #2
0
 public virtual void GetLineByDataRow(DataRow dataRow, ref TempLineNode line)
 {
     if (dataRow != null)
     {
         line.LineNodeID = dataRow["LineID"] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow["LineID"]);
         line.X1         = dataRow["PX1"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PX1"]);
         line.Y1         = dataRow["PY1"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PY1"]);
         line.X2         = dataRow["PX2"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PX2"]);
         line.Y2         = dataRow["PY2"] == System.DBNull.Value ? 0.0 : Convert.ToDouble(dataRow["PY2"]);
         line.IsReverse  = dataRow[5] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow[5]);
     }
 }
Exemple #3
0
        /// <summary>
        /// 处理面图层中构面线之间的关系
        /// </summary>
        public void MatchPolygonLine(/*ref int nNewEntityID*/)
        {
            /*Update LineNodeEx Set EntityID=nNewEntityID+LineNodeID  Where LineNodeEx.EntityID=-1
             *
             * Update LineNodeEx a,LineNodeEx b Set a.EntityID=b.EntityID,a.IsReverse='1',b.OrtherIndexID=a.IndexID,a.OrtherIndexID=b.IndexID Where
             * (a.X2-b.X1)*(a.X2-b.X1)<0.000001"
                + " and (a.Y2-b.Y1)*(a.Y2-b.Y1)<0.000001"
                + " and (a.X1-b.X2)*(a.X1-b.X2)<0.000001"
                + " and (a.Y1-b.Y2)*(a.Y1-b.Y2)<0.000001"//  and LineNodeEx.EntityID=-1
             *
             * Select * from (Select IndexID as ID,X1 as PX1,Y1 as PY1,X2 as PX2,Y2 as PY2,0 LineNodeEx Where EntityID=-1 union Select IndexID as ID,X2 as PX1,Y2 as PY1,X1 as PX2,Y1 as PY2,1 LineNodeEx Where EntityID=-1)
             * Order By PX1,PY1,PX2,PY2
             * */
            if (this.m_pOleDbConnection != null && m_pOleDbConnection.State == ConnectionState.Open)
            {
                //查找匹配项,并写入临时表
                MatchLineNodeExTable matchLineNodeTable = new MatchLineNodeExTable(m_pOleDbConnection, true, this.IsFirst);

                LineNodeExView lineNodeExView = new LineNodeExView(m_pOleDbConnection);
                DataTable dataViewLineNodeEx = lineNodeExView.GetRecords("", "", "");

                TempLineNode tempLineNodeUp = null;
                TempLineNode tempLineNode = null;
                bool bNeedSave = false;
                int n = 0;
                while (dataViewLineNodeEx.Rows.Count > 0)
                {
                    for (int i = 0; i < dataViewLineNodeEx.Rows.Count; i++)
                    {
                        tempLineNode = new TempLineNode();
                        lineNodeExView.GetLineByDataRow(dataViewLineNodeEx.Rows[i], ref tempLineNode);

                        if (tempLineNode == tempLineNodeUp)
                        {
                            if (tempLineNodeUp.IsReverse == -1)
                            {
                                matchLineNodeTable.AddRow(tempLineNodeUp.LineNodeID, tempLineNode.LineNodeID, tempLineNodeUp.IsReverse, tempLineNode.IsReverse/*, nNewEntityID++*/);

                                n++;
                            }
                        }

                        tempLineNodeUp = tempLineNode;
                    }

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

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

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

                if (bNeedSave == true)
                {
                    //更新匹配到的线索引
                    string strCommand = "";
                    strCommand = "Update LineNodeEx,MatchLineNodeEx Set LineNodeEx.OrtherLineNodeID=MatchLineNodeEx.Index2,LineNodeEx.IsReverse=Reverse1 Where LineNodeEx.LineNodeID=MatchLineNodeEx.Index1";//LineNodeEx.EntityID=MatchLineNodeEx.EntityID,
                    matchLineNodeTable.ExecuteNonQuery(strCommand);

                    strCommand = "Update LineNodeEx,MatchLineNodeEx Set LineNodeEx.OrtherLineNodeID=MatchLineNodeEx.Index1,LineNodeEx.IsReverse=Reverse2 Where LineNodeEx.LineNodeID=MatchLineNodeEx.Index2";//LineNodeEx.EntityID=MatchLineNodeEx.EntityID,
                    matchLineNodeTable.ExecuteNonQuery(strCommand);
                }

                ////给未匹配到的线实体分配标识码
                //LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection, false);

                //string strWhere = pLineNodeExTable.FieldName_EntityID + "<>0 And " + pLineNodeExTable.FieldName_IsFromLine + "='0'";
                //DataTable dataTableLineNodeEx = pLineNodeExTable.GetRecords(strWhere, "", "");
                //while (dataTableLineNodeEx.Rows.Count > 0)
                //{
                //    for (int i = 0; i < dataTableLineNodeEx.Rows.Count; i++)
                //    {
                //        //必须是未找到标识码的
                //        if (Convert.ToInt32(dataTableLineNodeEx.Rows[i][pLineNodeExTable.FieldName_EntityID]) != -1)
                //            continue;
                //        //需要创建要素编码
                //        pLineNodeExTable.SetLineNodeEntityID(dataTableLineNodeEx.Rows[i], nNewEntityID++, false);
                //    }

                //    pLineNodeExTable.Save(false);

                //    if (dataTableLineNodeEx.Rows.Count < pLineNodeExTable.MaxRecordCount)
                //        break;
                //    dataTableLineNodeEx = pLineNodeExTable.GetNextRecords();
                //}
                /*
                string commandText = "Select * from "
                    + "(Select IndexID as ID,X1 as PX1,Y1 as PY1,X2 as PX2,Y2 as PY2,0 LineNodeEx Where EntityID=-1 "
                    + "union Select IndexID as ID,X2 as PX1,Y2 as PY1,X1 as PX2,Y1 as PY2,1 LineNodeEx Where EntityID=-1) "
                    + "Order By PX1,PY1,PX2,PY2";

                OleDbDataAdapter pOleDbDataAdapter = new OleDbDataAdapter(commandText, m_pOleDbConnection);

                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(pOleDbDataAdapter);
                DataSet pDataSet = new DataSet();

                int nCurrentRowIndex = 0;
                nCurrentRowIndex += pOleDbDataAdapter.Fill(pDataSet, nCurrentRowIndex, 10000, "Table");
                if (pDataSet.Tables != null && pDataSet.Tables.Count > 0)
                {
                    DataTable pDataTable = pDataSet.Tables[0];

                    for (int i = 0; i < pDataTable.Rows.Count; i++)
                    {
                    }

                }
                 * */

            }

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

                string strLineNodeExOrderBy = pLineNodeExTable.FieldName_X1 + ","
                    + pLineNodeExTable.FieldName_Y1 + ","
                    + pLineNodeExTable.FieldName_X2 + ","
                    + pLineNodeExTable.FieldName_Y2 + ","
                    + pLineNodeExTable.FieldName_EntityID;
                //必须是未找到标识码的
                string strWhere = pLineNodeExTable.FieldName_EntityID + "=-1";
                DataTable dataTableLineNodeEx = pLineNodeExTable.GetRecords(strWhere, "", strLineNodeExOrderBy);

                string strLineNodeExOrderByReverse = pLineNodeExTable.FieldName_X2 + ","
                   + pLineNodeExTable.FieldName_Y2 + ","
                   + pLineNodeExTable.FieldName_X1 + ","
                   + pLineNodeExTable.FieldName_Y1 + ","
                   + pLineNodeExTable.FieldName_EntityID;
                LineNodeExTable pLineNodeExTableReverse = new LineNodeExTable(m_pOleDbConnection, false);
                DataTable dataTableLineNodeExReverse = pLineNodeExTableReverse.GetRecords(strWhere, "", strLineNodeExOrderByReverse);

                //DataRow[] dataRows = dataTableLineNodeEx.Select("", strLineNodeExOrderBy2);

                int k = 0;
                int j = 0;
                for (int i = 0; i < dataTableLineNodeEx.Rows.Count; i++)
                {
                    LineNode lineNodeEx = new LineNodeEx();
                    pLineNodeExTable.GetLineNodeByDataRow(dataTableLineNodeEx.Rows[i], ref lineNodeEx, false);

                    //需要创建要素编码
                    lineNodeEx.EntityID = nNewEntityID++;
                    pLineNodeExTable.SetLineNodeEntityID(dataTableLineNodeEx.Rows[i], lineNodeEx.EntityID, false);

                    for (; j < dataTableLineNodeExReverse.Rows.Count; j++)
                    {
                        LineNode lineNodeExReverse = new LineNodeEx();
                        pLineNodeExTable.GetLineNodeByDataRow(dataTableLineNodeExReverse.Rows[j], ref lineNodeExReverse, true);
                        if (lineNodeExReverse.EntityID == -1)
                        {
                            if (lineNodeEx == lineNodeExReverse)
                            {
                                //arrLineNodeNewClone[j].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
                                //arrLineNodeNewClone[j].InitiallyLineNode.Reverse();
                                pLineNodeExTableReverse.SetLineNodeEntityID(dataTableLineNodeExReverse.Rows[j], lineNodeEx.EntityID, true);

                                //arrLineNodeNewClone[j].InitiallyLineNode.OtherPolygonLineNode = arrLineNodeExNew[i];
                                //arrLineNodeExNew[i].OtherPolygonLineNode = arrLineNodeNewClone[j].InitiallyLineNode;
                                pLineNodeExTableReverse.SetOtherPolygonLineNode(dataTableLineNodeExReverse.Rows[j], lineNodeEx.IndexID);
                                pLineNodeExTable.SetOtherPolygonLineNode(dataTableLineNodeEx.Rows[i], lineNodeExReverse.IndexID);
                                k++;
                            }
                            if (lineNodeEx > lineNodeExReverse)
                            {
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    if ((k + 1) % 10000 == 0)
                    {
                        pLineNodeExTable.Save(false);
                        pLineNodeExTableReverse.Save(false);
                    }
                }
                if (k > 0)
                {
                    pLineNodeExTable.Save(true);
                    pLineNodeExTableReverse.Save(true);
                }
            }
             * */
        }