Пример #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();
        }
Пример #2
0
        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
        }
Пример #3
0
        public override void OnClick()
        {
            /*  执行接边要素的搜索
             *  基本过程:
             *    1.获取基本参数信息:图幅结合表的图层、参与接边图层列表、接边参数(从配置xml文件中获取);
             *    2.实现IMapframe接口,通过接口获取接边的源、目标缓冲区域、接边边界;
             *    3.(接边要素粗选)实现IDestinatDataset接口,使用(2)返回的缓冲区域通过接口获取待接边源要素、目标要素的OID集合;
             *    4.(接边要素精选)实现ICheckOperation接口,通过接口在步骤(3)的OID集合中判断接边情况和属性匹配情况(若FieldsControlList不赋值,则不进行属性控制);
             *    5.将接口ICheckOperation返回的信息反映到界面上。
             */
            frmJoinFeaSearch FeaSearch      = new frmJoinFeaSearch();
            List <string>    JoinFeaClsName = null;
            Dictionary <string, List <string> > JoinField = new Dictionary <string, List <string> >();//////接边控制字段
            string MapFrameName  = string.Empty;
            string MapFrameField = "";

            if (System.Windows.Forms.DialogResult.OK == FeaSearch.ShowDialog())
            {
                JoinFeaClsName = FeaSearch.JoinLayerName;
                JoinField      = FeaSearch.FieldDic;
                MapFrameName   = FeaSearch.MapFrameName;
                MapFrameField  = FeaSearch.MapFrameField;
                IFeatureClass MapFrameFeaClss = null;
                #region 获取图幅范围
                int layercount = m_Hook.ArcGisMapControl.LayerCount;
                for (int i = 0; i < layercount; i++)
                {
                    ILayer getlayer = m_Hook.ArcGisMapControl.get_Layer(i);
                    if (getlayer.Name == MapFrameName)
                    {
                        IFeatureLayer FeaLayer = getlayer as IFeatureLayer;
                        MapFrameFeaClss = FeaLayer.FeatureClass;
                    }
                }
                #endregion
                List <IFeatureClass> JoinFeaCls = new List <IFeatureClass>();
                m_Hook.PolylineSearchGrid.Tag = JoinFeaCls;//////将待接边的图层列表挂在PolylineSearchGrid.Tag上供使用
                #region 获取接边图层列表
                layercount = m_Hook.ArcGisMapControl.LayerCount;
                for (int i = 0; i < layercount; i++)
                {
                    ILayer getlayer = m_Hook.ArcGisMapControl.get_Layer(i);
                    if (JoinFeaClsName.Contains(getlayer.Name))
                    {
                        IFeatureLayer FeaLayer   = getlayer as IFeatureLayer;
                        IFeatureClass getFeaClss = FeaLayer.FeatureClass;
                        JoinFeaCls.Add(getFeaClss);
                    }
                }
                #endregion
                double dDisTo     = -1;
                double dSeacherTo = -1;
                double dAngleTo   = -1;
                double dLengthTo  = -1;
                #region 获取接边参数
                XmlDocument XmlDoc = new XmlDocument();
                XmlDoc.Load(ModData.v_JoinSettingXML);
                if (null == XmlDoc)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取接边参数配置文件失败!");
                    return;
                }
                XmlElement ele = XmlDoc.SelectSingleNode(".//接边设置") as XmlElement;

                string sDisTo       = ele.GetAttribute("距离容差");
                string sSeacherTo   = ele.GetAttribute("搜索容差");
                string sAngleTo     = ele.GetAttribute("角度容差");
                string sLengthTo    = ele.GetAttribute("长度容差");
                string sJoinType    = ele.GetAttribute("接边类型");
                string sIsRemovePnt = ele.GetAttribute("删除多边形多余点").Trim();
                string sIsSimplify  = ele.GetAttribute("简单化要素").Trim();
                try
                {
                    dDisTo     = Convert.ToDouble(sDisTo);
                    dSeacherTo = Convert.ToDouble(sSeacherTo);
                    dAngleTo   = Convert.ToDouble(sAngleTo);
                    dLengthTo  = Convert.ToDouble(sLengthTo);
                }
                catch
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边参数配置文件中参数不正确!");
                    return;
                }
                #endregion
                if (MapFrameFeaClss == null)
                {
                    return;
                }
                int            max          = MapFrameFeaClss.FeatureCount(null);
                IFeatureCursor JoinFrameCur = MapFrameFeaClss.Search(null, false);
                IFeature       MapFrameFea  = JoinFrameCur.NextFeature();

                IMapframe pMapframe = null;//////////接边图幅类初始化(标准图幅接边或非标准图幅接边)
                if (sJoinType == "标准图幅")
                {
                    pMapframe = new ClsMapFrame();
                }
                else
                {
                    pMapframe = new ClsTaskFrame();
                }
                pMapframe.MapFrameFea = MapFrameFeaClss;
                FrmProcessBar ProcessBar = new FrmProcessBar(max);
                ProcessBar.Show();
                ProcessBar.SetFrmProcessBarText("正在搜索接边要素");
                long value = 0;
                this.m_PolyLineSearchTable.Rows.Clear();
                this.m_PolygonSearchTable.Rows.Clear();
                IDestinatDataset DesData = null;
                if (sJoinType == "标准图幅")
                {
                    DesData = new ClsDestinatDataset(true);/////标准图幅接边搜索
                }
                else
                {
                    DesData = new ClsDestinatDataset(false);/////非标准图幅接边搜索
                }
                /////////////////////////////////
                DesData.Angle_to = dAngleTo;
                if (sIsRemovePnt == "Y")//////删除多边形上多余的点
                {
                    DesData.IsRemoveRedundantPnt = true;
                }
                else
                {
                    DesData.IsRemoveRedundantPnt = false;
                }

                if (sIsSimplify == "Y")///////要素简单化(针对有多个geometry的要素)
                {
                    DesData.IsGeometrySimplify = true;
                }
                else
                {
                    DesData.IsGeometrySimplify = false;
                }
                //////////////////////////////////////
                ele = XmlDoc.SelectSingleNode(".//日志设置") as XmlElement;
                string sLogPath = ele.GetAttribute("日志路径").Trim();



                DesData.JoinFeatureClass = JoinFeaCls;
                //////遍历每一个图幅搜索接边要素/////
                if (!string.IsNullOrEmpty(sLogPath))
                {
                    IJoinLOG  JoinLog = new ClsJoinLog();
                    Exception ex      = null;
                    JoinLog.onDataJoin_Start(0, out ex);
                }
                while (MapFrameFea != null)
                {
                    value += 1;
                    ProcessBar.SetFrmProcessBarValue(value);
                    Application.DoEvents();
                    int    index = MapFrameFea.Fields.FindField(MapFrameField);
                    string No    = string.Empty;
                    try
                    {
                        if (index > 0)
                        {
                            No = MapFrameFea.get_Value(index).ToString();
                        }
                    }
                    catch
                    {
                        No = string.Empty;
                    }
                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No);
                    Application.DoEvents();
                    pMapframe.OriMapFrame = MapFrameFea;

                    IGeometry OriArea = null;
                    IGeometry DesArea = null;
                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在生成缓冲区");
                    Application.DoEvents();
                    try
                    {
                        pMapframe.GetBufferArea(dDisTo, out OriArea, out DesArea);
                    }
                    catch
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "生成接边搜索缓冲区失败!\n请检查图幅范围图层是否设置正确。");
                        ProcessBar.Close();
                        return;
                    }
                    ////////////////////////////////////
                    //IElement ele2 = null;
                    //IPolygonElement pPolElemnt = new PolygonElementClass();
                    //IFillShapeElement pFillShapeElement = (IFillShapeElement)pPolElemnt;
                    //pFillShapeElement.Symbol = GetDrawSymbol(0, 255, 0);
                    //ele2 = pFillShapeElement as IElement;
                    //ele2.Geometry = DesArea;
                    //IGraphicsContainer pMapGraphics = (IGraphicsContainer)m_Hook.ArcGisMapControl.Map;
                    //pMapGraphics.AddElement(ele2, 0);
                    //m_Hook.ArcGisMapControl.ActiveView.Refresh();

                    //IElement ele3 = null;
                    //pPolElemnt = new PolygonElementClass();
                    //pFillShapeElement = (IFillShapeElement)pPolElemnt;
                    //pFillShapeElement.Symbol = GetDrawSymbol(255, 0, 0);
                    //ele3 = pFillShapeElement as IElement;
                    //ele3.Geometry = OriArea;
                    ////IGraphicsContainer pMapGraphics = (IGraphicsContainer)this.axMapControl.Map;
                    //pMapGraphics.AddElement(ele3, 0);

                    /////////////////////////////////////
                    if (!string.IsNullOrEmpty(No))
                    {
                        ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + ",正在获取接边要素");
                    }
                    else
                    {
                        ProcessBar.SetFrmProcessBarText("正在获取接边要素");
                    }
                    Application.DoEvents();
                    Dictionary <string, List <long> > OriOidDic = DesData.GetFeaturesByGeometry(OriArea, true);  ////接边源要素记录
                    Dictionary <string, List <long> > DesOidDic = DesData.GetFeaturesByGeometry(DesArea, false); ////接边目标要素记录
                    ICheckOperation CheckOper = new ClsCheckOperationer();
                    CheckOper.Angel_Tolerrance  = dAngleTo;                                                      /////////////角度容差
                    CheckOper.borderline        = pMapframe.Getborderline();                                     //接边边界
                    CheckOper.Dis_Tolerance     = dDisTo;                                                        //////////////////距离容差
                    CheckOper.Search_Tolerrance = dSeacherTo;                                                    //////////搜索容差
                    CheckOper.Length_Tolerrance = dLengthTo;                                                     ///////////长度容差
                    CheckOper.DesBufferArea     = DesArea;                                                       /////////////////目标搜索缓冲区
                    CheckOper.OriBufferArea     = OriArea;                                                       /////////////////源搜索缓冲区

                    if (!string.IsNullOrEmpty(sLogPath))
                    {
                        CheckOper.CreatLog = true;
                    }
                    else
                    {
                        CheckOper.CreatLog = false;
                    }
                    if (null != OriOidDic)
                    {
                        foreach (KeyValuePair <string, List <long> > item in OriOidDic)
                        {
                            string OriFeaName = item.Key;
                            if (!string.IsNullOrEmpty(No))
                            {
                                ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + ",正在搜索图层:" + OriFeaName);
                            }
                            else
                            {
                                ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName);
                            }
                            Application.DoEvents();
                            List <long> OriFeaOIDL = item.Value;
                            List <long> DesFeaOIDL = null;
                            if (DesOidDic == null)
                            {
                                continue;
                            }
                            if (DesOidDic.ContainsKey(OriFeaName))
                            {
                                DesFeaOIDL = DesOidDic[OriFeaName];
                            }
                            if (null != OriFeaOIDL && null != DesFeaOIDL)
                            {
                                CheckOper.DesFeaturesOID = DesFeaOIDL;
                                CheckOper.OriFeaturesOID = OriFeaOIDL;
                                IFeatureClass JoinFea = DesData.TargetFeatureClass(OriFeaName);
                                if (null != JoinFeaCls)
                                {
                                    CheckOper.DestinatFeaCls = JoinFea;
                                    if (null != JoinField)
                                    {
                                        foreach (KeyValuePair <string, List <string> > getitem in JoinField)
                                        {
                                            if (getitem.Key == (JoinFea as IDataset).Name)
                                            {
                                                CheckOper.FieldsControlList = getitem.Value;
                                            }
                                        }
                                    }
                                    esriGeometryType GeoType = CheckOper.GetDatasetGeometryType();
                                    if (GeoType == esriGeometryType.esriGeometryPolyline)
                                    {
                                        if (!string.IsNullOrEmpty(No))
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + ",正在搜索图层:" + OriFeaName + ",操作:线型要素记录");
                                        }
                                        else
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:线型要素记录");
                                        }
                                        Application.DoEvents();
                                        DataTable table = CheckOper.GetPolylineDesFeatureOIDByOriFeature();
                                        if (null != table)
                                        {
                                            for (int i = 0; i < table.Rows.Count; i++)
                                            {
                                                if (!string.IsNullOrEmpty(No))
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                else
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                Application.DoEvents();
                                                this.m_PolyLineSearchTable.Rows.Add(table.Rows[i].ItemArray);
                                            }
                                        }
                                    }
                                    if (GeoType == esriGeometryType.esriGeometryPolygon)
                                    {
                                        if (!string.IsNullOrEmpty(No))
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在搜索图层:" + OriFeaName + ",操作:多边形要素记录");
                                        }
                                        else
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:多边形要素记录");
                                        }
                                        Application.DoEvents();
                                        DataTable table = CheckOper.GetPolygonDesFeatureOIDByOriFeature();
                                        if (null != table)
                                        {
                                            for (int i = 0; i < table.Rows.Count; i++)
                                            {
                                                if (!string.IsNullOrEmpty(No))
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                else
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                Application.DoEvents();
                                                this.m_PolygonSearchTable.Rows.Add(table.Rows[i].ItemArray);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    MapFrameFea = JoinFrameCur.NextFeature();
                }
                if (!string.IsNullOrEmpty(sLogPath))
                {
                    IJoinLOG  JoinLog = new ClsJoinLog();
                    Exception ex      = null;
                    JoinLog.onDataJoin_Terminate(0, out ex);
                }
                m_Hook.PolygonSearchGrid.DataSource  = null;
                m_Hook.PolylineSearchGrid.DataSource = null;
                m_Hook.PolygonSearchGrid.DataSource  = this.m_PolygonSearchTable;
                m_Hook.PolylineSearchGrid.DataSource = this.m_PolyLineSearchTable;
                SelectALL(m_Hook.PolylineSearchGrid);
                SelectALL(m_Hook.PolygonSearchGrid);
                MessageBox.Show("线记录个数:" + this.m_PolyLineSearchTable.Rows.Count + ";面记录个数:" + this.m_PolygonSearchTable.Rows.Count);
                ProcessBar.Close();
            }
        }
Пример #4
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.com_jointype.Text))
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择一个接边类型!");
                return;
            }
            if (string.IsNullOrEmpty(this.com_MergeAtrSet.Text))
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择要素融合属性数据处理类型!");
                return;
            }
            double      dDisTo     = this.con_DisTo.Value;;
            double      dSeacherTo = this.con_SearchTo.Value;
            double      dAngleTo   = this.con_AngleTo.Value;
            double      dLengthTo  = this.con_LengthTo.Value;
            XmlDocument XmlDoc     = new XmlDocument();

            XmlDoc.Load(ModData.v_JoinSettingXML);
            if (null == XmlDoc)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取接边参数配置文件失败!");
                return;
            }
            XmlElement ele = XmlDoc.SelectSingleNode(".//接边设置") as XmlElement;

            ele.SetAttribute("距离容差", dDisTo.ToString());
            ele.SetAttribute("搜索容差", dSeacherTo.ToString());
            ele.SetAttribute("角度容差", dAngleTo.ToString());
            ele.SetAttribute("长度容差", dLengthTo.ToString());
            ele.SetAttribute("接边类型", this.com_jointype.Text.Trim());
            if (this.check_RemovePoPnt.Checked == true)
            {
                ele.SetAttribute("删除多边形多余点", "Y");
            }
            else
            {
                ele.SetAttribute("删除多边形多余点", "N");
            }

            if (this.check_Simplify.Checked == true)
            {
                ele.SetAttribute("简单化要素", "Y");
            }
            else
            {
                ele.SetAttribute("简单化要素", "N");
            }

            XmlElement ele2 = XmlDoc.SelectSingleNode(".//融合设置") as XmlElement;

            if (this.com_MergeAtrSet.Text.Trim() == "添加到源要素")
            {
                ele2.SetAttribute("属性覆盖", "N");
            }
            else
            {
                ele2.SetAttribute("属性覆盖", "Y");
            }
            XmlElement ele3 = XmlDoc.SelectSingleNode(".//日志设置") as XmlElement;

            if (this.logcheck.Checked == true)
            {
                if (!string.IsNullOrEmpty(this.label_LogPath.Text))
                {
                    ele3.SetAttribute("日志路径", this.label_LogPath.Text.Trim());
                }
            }
            else
            {
                ele3.SetAttribute("日志路径", string.Empty);
            }

            try
            {
                XmlDoc.Save(ModData.v_JoinSettingXML);
            }
            catch (Exception er)
            {
                //*******************************************************************
                //guozheng added
                if (ModData.SysLog != null)
                {
                    ModData.SysLog.Write(er, null, DateTime.Now);
                }
                else
                {
                    ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    ModData.SysLog.Write(er, null, DateTime.Now);
                }
                //********************************************************************
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边配置文件参数写入失败!\n 请确认文件是否只读:\n" + ModData.v_JoinSettingXML);
                return;
            }
            if (this.logcheck.Checked == true)
            {
                IJoinLOG  JoinLog = new ClsJoinLog();
                Exception ex      = null;
                JoinLog.InitialLog(out ex);
                if (null != ex)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
                    return;
                }
            }
            this.Close();
        }