Beispiel #1
0
        public override void OnClick()
        {
            if (ModData.v_AppGIS.PolygonSearchGrid.DataSource == null && ModData.v_AppGIS.PolylineSearchGrid.DataSource == null)
            {
                return;
            }
            this.JoinResultTable.Rows.Clear();
            m_Hook.JoinMergeResultGrid.DataSource = null;
            List <IFeatureClass> FeaClsList = m_Hook.PolylineSearchGrid.Tag as List <IFeatureClass>;

            if (null == FeaClsList)
            {
                return;
            }
            IJoinOperation JoinOper = new ClsJoinOperationer();

            JoinOper.JoinFeaClss = FeaClsList;
            FrmProcessBar ProcessBar = new FrmProcessBar();

            ProcessBar.Text = "开始执行接边";//xisheng 20110901
            ProcessBar.Show();
            /////////
            XmlDocument Doc = new XmlDocument();

            Doc.Load(ModData.v_JoinSettingXML);
            bool      IsCreatLog = false;
            Exception ex         = null;

            if (Doc != null)
            {
                XmlElement ele     = Doc.SelectSingleNode(".//日志设置") as XmlElement;
                string     LogPath = ele.GetAttribute("日志路径").Trim();
                if (string.IsNullOrEmpty(LogPath))
                {
                    IsCreatLog = false;
                }
                else
                {
                    IsCreatLog = true;
                }
            }
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Start(1, out ex);
                JoinOper.CreatLog = true;
            }
            else
            {
                JoinOper.CreatLog = false;
            }
            /////////
            if (null != m_Hook.PolylineSearchGrid.DataSource)/////线的接边
            {
                GetPolylineTable.Rows.Clear();
                DataTable TemTable = m_Hook.PolylineSearchGrid.DataSource as DataTable;
                for (int i = 0; i < m_Hook.PolylineSearchGrid.Rows.Count; i++)////遍历线型接边搜索表将选中的行记录下来
                {
                    if (m_Hook.PolylineSearchGrid.Rows[i].Cells[0].Value == null)
                    {
                        continue;
                    }
                    if (((bool)m_Hook.PolylineSearchGrid.Rows[i].Cells[0].Value) == true)
                    {
                        GetPolylineTable.Rows.Add(TemTable.Rows[i].ItemArray);
                    }
                }
                if (null != GetPolylineTable)
                {
                    DataTable mergeTable = JoinOper.MovePolylinePnt(GetPolylineTable);
                    if (null != mergeTable)
                    {
                        ProcessBar.SetFrmProcessBarMax(mergeTable.Rows.Count);
                        for (int i = 0; i < mergeTable.Rows.Count; i++)
                        {
                            ProcessBar.SetFrmProcessBarText("正在进行线的接边:");
                            ProcessBar.SetFrmProcessBarValue(i);
                            System.Windows.Forms.Application.DoEvents();
                            this.JoinResultTable.Rows.Add(mergeTable.Rows[i].ItemArray);
                        }
                    }
                }
            }
            if (null != m_Hook.PolygonSearchGrid.DataSource)/////多边形的接边
            {
                GetPolygonTable.Rows.Clear();
                DataTable TemTable = m_Hook.PolygonSearchGrid.DataSource as DataTable;
                for (int i = 0; i < m_Hook.PolygonSearchGrid.Rows.Count; i++)////遍历线型接边搜索表将选中的行记录下来
                {
                    if (m_Hook.PolygonSearchGrid.Rows[i].Cells[0].Value == null)
                    {
                        continue;
                    }
                    if (((bool)m_Hook.PolygonSearchGrid.Rows[i].Cells[0].Value) == true)
                    {
                        GetPolygonTable.Rows.Add(TemTable.Rows[i].ItemArray);
                    }
                }
                if (null != GetPolygonTable)
                {
                    DataTable mergeTable = JoinOper.MovePolygonPnt(GetPolygonTable);
                    if (null != mergeTable)
                    {
                        ProcessBar.SetFrmProcessBarMax(mergeTable.Rows.Count);
                        for (int i = 0; i < mergeTable.Rows.Count; i++)
                        {
                            ProcessBar.SetFrmProcessBarText("正在进行多边形的接边:");
                            ProcessBar.SetFrmProcessBarValue(i);
                            System.Windows.Forms.Application.DoEvents();
                            this.JoinResultTable.Rows.Add(mergeTable.Rows[i].ItemArray);
                        }
                    }
                }
            }
            //m_Hook.PolylineSearchGrid.DataSource = null;
            //m_Hook.PolygonSearchGrid.DataSource = null;
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Terminate(1, out ex);
            }
            m_Hook.JoinMergeResultGrid.DataSource = this.JoinResultTable;
            ControlsDataJoinSearch.SelectALL(m_Hook.JoinMergeResultGrid);
            ProcessBar.Close();
        }
        public override void OnClick()
        {
            if (m_Hook.JoinMergeResultGrid.DataSource == null)
            {
                return;
            }
            if (((DataTable)m_Hook.JoinMergeResultGrid.DataSource).TableName != "JoinResultTable")
            {
                return;
            }
            List <IFeatureClass> MergeFeaClsList = null;
            ////////获取融合参数///////
            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.Load(ModData.v_JoinSettingXML);
            if (null == XmlDoc)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取融合参数配置文件失败!");
                return;
            }
            XmlElement ele            = XmlDoc.SelectSingleNode(".//融合设置") as XmlElement;
            string     sIsDesAtrToOri = ele.GetAttribute("属性覆盖").Trim();

            ////////

            MergeFeaClsList = m_Hook.PolylineSearchGrid.Tag as List <IFeatureClass>;
            if (null == MergeFeaClsList)
            {
                return;
            }
            IMergeOperation Meroper = new ClsMergeOperationer();

            Meroper.JoinFeaClss = MergeFeaClsList;
            //////////融合要素属性处理选择////////
            if (sIsDesAtrToOri == "Y")
            {
                Meroper.SetDesValueToOri = true;
            }
            else
            {
                Meroper.SetDesValueToOri = false;
            }
            /////////日志
            bool      IsCreatLog = false;
            Exception ex         = null;

            if (XmlDoc != null)
            {
                XmlElement ele2    = XmlDoc.SelectSingleNode(".//日志设置") as XmlElement;
                string     LogPath = ele2.GetAttribute("日志路径").Trim();
                if (string.IsNullOrEmpty(LogPath))
                {
                    IsCreatLog       = false;
                    Meroper.CreatLog = false;
                }
                else
                {
                    IsCreatLog       = true;
                    Meroper.CreatLog = true;
                }
                //////////////////日志中属性处理记录信息
                string sAttriPro = string.Empty;
                if (sIsDesAtrToOri == "Y")
                {
                    sAttriPro = "覆盖";
                }
                else
                {
                    sAttriPro = "累加";
                }
                /////////////若日志存在则记录到日志当中
                if (!string.IsNullOrEmpty(LogPath))
                {
                    try
                    {
                        XmlDocument Doc = new XmlDocument();
                        Doc.Load(LogPath);
                        if (null != Doc)
                        {
                            XmlElement Setele = Doc.SelectSingleNode(".//融合操作/参数") as XmlElement;
                            Setele.SetAttribute("属性处理", sAttriPro);
                            Doc.Save(LogPath);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Start(2, out ex);
            }
            /////////
            DataTable  UnionResTable = new DataTable();
            DataColumn dc1           = new DataColumn("数据集", Type.GetType("System.String"));
            DataColumn dc2           = new DataColumn("要素类型", Type.GetType("System.String"));
            DataColumn dc3           = new DataColumn("源要素ID", Type.GetType("System.Int64"));

            dc3.DefaultValue = -1;
            DataColumn dc4 = new DataColumn("目标要素ID", Type.GetType("System.Int64"));

            dc4.DefaultValue = -1;
            DataColumn dc5 = new DataColumn("处理结果", Type.GetType("System.String"));

            UnionResTable.Columns.Add(dc1);
            UnionResTable.Columns.Add(dc2);
            UnionResTable.Columns.Add(dc3);
            UnionResTable.Columns.Add(dc4);
            UnionResTable.Columns.Add(dc5);
            DataTable JoinResultTable = m_Hook.JoinMergeResultGrid.DataSource as DataTable;

            /////////////////
            // DataTable UnionResTable = JoinResultTable;
            UnionResTable.TableName = "MergeResultTable";
            //  UnionResTable.Rows.Clear();
            if (JoinResultTable != null) //////融合操作(考虑多个要素相互融合的情况)
            {
                FrmProcessBar ProcessBar = new FrmProcessBar(JoinResultTable.Rows.Count);
                int           max        = JoinResultTable.Rows.Count;
                ProcessBar.Show();

                while (JoinResultTable.Rows.Count > 0)
                {
                    List <int>  lDeleRowNo = new List <int>();
                    long        OriFeaOID  = -1;
                    List <long> lDesFeaOID = new List <long>();
                    /////获取第一行
                    string DataSetName = string.Empty;
                    string type        = string.Empty;
                    long   OriOID      = -1;
                    long   DesOID      = -1;
                    string result      = string.Empty;
                    try
                    {
                        DataSetName = JoinResultTable.Rows[0]["数据集"].ToString().Trim();
                        type        = JoinResultTable.Rows[0]["要素类型"].ToString().Trim();
                        OriOID      = Convert.ToInt64(JoinResultTable.Rows[0]["源要素ID"].ToString());
                        DesOID      = Convert.ToInt64(JoinResultTable.Rows[0]["目标要素ID"].ToString());
                        result      = JoinResultTable.Rows[0]["处理结果"].ToString().Trim();
                    }
                    catch
                    {
                        return;
                    }
                    OriFeaOID = OriOID;
                    ProcessBar.SetFrmProcessBarText("处理要素:" + OriFeaOID);
                    ProcessBar.SetFrmProcessBarValue(max - JoinResultTable.Rows.Count);
                    System.Windows.Forms.Application.DoEvents();
                    if (result == "已接边")
                    {
                        lDesFeaOID.Add(DesOID);
                    }
                    lDeleRowNo.Add(0);
                    /////遍历剩下的行,若存在互接边关系记录到融合列表中,同时记录下这些行进行删除
                    #region 遍历剩下的行,若存在互接边关系记录到融合列表中,同时记录下这些行进行删除
                    //////做两次检索避免遗漏(当一条线多次穿越接边边界时,一次循环检索可能会遗漏部分融合要素,两次循环使遗漏减至最少)
                    GetAllunionFea(OriOID, ref lDesFeaOID, ref lDeleRowNo, JoinResultTable, type, DataSetName);
                    GetAllunionFea(OriOID, ref lDesFeaOID, ref lDeleRowNo, JoinResultTable, type, DataSetName);
                    #endregion
                    //////融合记录列表中的要素
                    string sunionres = string.Empty;
                    #region  融合记录列表中的要素
                    if (lDesFeaOID != null && OriFeaOID != -1)
                    {
                        for (int i = 0; i < lDesFeaOID.Count; i++)
                        {
                            long UnioOid = lDesFeaOID[i];
                            ProcessBar.SetFrmProcessBarText("融合要素:" + OriFeaOID + "," + UnioOid);
                            System.Windows.Forms.Application.DoEvents();
                            if (type == "Polyline")
                            {
                                if (Meroper.MergePolyline(DataSetName, OriFeaOID, UnioOid))
                                {
                                    sunionres = "已融合";
                                }
                                else
                                {
                                    sunionres = "未融合";
                                }
                            }
                            else if (type == "Polygon")
                            {
                                if (Meroper.MergePolygon(DataSetName, OriFeaOID, UnioOid))
                                {
                                    sunionres = "已融合";
                                }
                                else
                                {
                                    sunionres = "未融合";
                                }
                            }
                        }
                    }
                    #endregion
                    DataRow addrow = UnionResTable.NewRow();
                    addrow["数据集"]    = DataSetName;
                    addrow["要素类型"]   = type;
                    addrow["源要素ID"]  = OriFeaOID;
                    addrow["目标要素ID"] = 0;
                    addrow["处理结果"]   = sunionres;
                    UnionResTable.Rows.Add(addrow);

                    #region  除行
                    if (null != lDeleRowNo)
                    {
                        for (int i = 0; i < lDeleRowNo.Count; i++)
                        {
                            JoinResultTable.Rows.Remove(JoinResultTable.Rows[lDeleRowNo[i] - i]);
                        }
                    }
                    #endregion
                }
                ProcessBar.Close();
            }
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Terminate(2, out ex);
            }
            //// JoinResultTable.TableName = "MergeResultTable";
            //// ((DataTable)m_Hook.JoinMergeResultGrid.DataSource).TableName = "MergeResultTable";
            m_Hook.JoinMergeResultGrid.DataSource = UnionResTable;
            ControlsDataJoinSearch.SelectALL(m_Hook.JoinMergeResultGrid); //选择所有;xisheng 20110901
        }