using SuperMap.Data; using SuperMap.Mapping; using System; using System.Data; using System.Drawing; using System.Windows.Forms; using WWPipeLine.MapBasic; using WWPipeLine.MapBasic.Conditions; namespace WWPipeLine.MapTools.Conditions.AnalystToolBar { public class DuanMian : BasicToolBar { private GeoLine m_TheLine; private Recordset m_Guanxian; public DuanMian() : base() { this.ConditionPanelName = "断面分析"; var startDrawToolStripButton = new ToolStripButton() { DisplayStyle = ToolStripItemDisplayStyle.ImageAndText, Text = "开始绘制断面", Name = "StartDraw", AutoToolTip = false }; var analystToolStripButton = new ToolStripButton() { DisplayStyle = ToolStripItemDisplayStyle.ImageAndText, Text = "分析", Name = "Analyst", AutoToolTip = false }; base.ToolStrip.Items.Add(startDrawToolStripButton); base.ToolStrip.Items.Add(analystToolStripButton); startDrawToolStripButton.Click += StartDrawToolStripButton_Click; analystToolStripButton.Click += AnalystToolStripButton_Click; } private void AnalystToolStripButton_Click(object sender, EventArgs e) { DataTable dt = new DataTable { TableName = "DuanMianAnalystResult" }; DataColumn dataColumn; dataColumn = new DataColumn { ColumnName = "dmgc", Caption = "地面高程(M)" }; dt.Columns.Add(dataColumn); dataColumn = new DataColumn { ColumnName = "gxgc", Caption = "管线高程(M)" }; dt.Columns.Add(dataColumn); dataColumn = new DataColumn { ColumnName = "gxms", Caption = "管线埋深(M)" }; dt.Columns.Add(dataColumn); dataColumn = new DataColumn { ColumnName = "gxgj", Caption = "管线管径(MM)" }; dt.Columns.Add(dataColumn); dataColumn = new DataColumn { ColumnName = "gxSMID", Caption = "管线ID" }; dt.Columns.Add(dataColumn); dataColumn = new DataColumn { ColumnName = "jl", Caption = "距离(M)" }; dt.Columns.Add(dataColumn); if (m_TheLine is null) return; Point2D m_TheLine_start = new Point2D(m_TheLine[0][0].X, m_TheLine[0][0].Y); Point2D m_TheLine_end = new Point2D(m_TheLine[0][1].X, m_TheLine[0][1].Y); Point2D m_Guanxian_start; Point2D m_Guanxian_end; Point2D m_JiaoDian; Point2D m_JiaoDian_temp = new Point2D(); double m_JiaoDian_jl = 0.0D; double m_Guanxian_start_ms = 0.0D; double m_Guanxian_end_ms = 0.0D; double m_JiaoDian_ms = 0.0D; double m_Guanxian_start_gc = 0.0D; double m_Guanxian_end_gc = 0.0D; double m_JiaoDian_gc = 0.0D; m_Guanxian.MoveFirst(); DataRow dr; DataTable dsJSJDPT2Count; dt.Rows.Clear(); while (!m_Guanxian.IsEOF) { dr = dt.NewRow(); dsJSJDPT2Count = ComsStatic.QueryDataTable(ComsStatic.dvJSJDPT, string.Format(" (bsm ='{0}' OR wth='{1}') AND ms is not null ", m_Guanxian.GetFieldValue("qsdh").ToString(), m_Guanxian.GetFieldValue("zddh").ToString())); if (dsJSJDPT2Count.Rows.Count == 2)//理论生只会查询到2条记录,分别是管线的起点物探号和终点物探号 { //获得管线的 起点坐标 起始埋深 终点坐标 终点埋深 来自管点JSJDPT数据 m_Guanxian_start = new Point2D(double.Parse(dsJSJDPT2Count.Rows[0]["x"].ToString()), double.Parse(dsJSJDPT2Count.Rows[0]["y"].ToString())); m_Guanxian_end = new Point2D(double.Parse(dsJSJDPT2Count.Rows[1]["x"].ToString()), double.Parse(dsJSJDPT2Count.Rows[1]["y"].ToString())); m_JiaoDian = Geometrist.IntersectLine(m_TheLine_start, m_TheLine_end, m_Guanxian_start, m_Guanxian_end, false); //开始计算交点的埋深数据 Double.TryParse(dsJSJDPT2Count.Rows[0]["ms"].ToString(), out m_Guanxian_start_ms); Double.TryParse(dsJSJDPT2Count.Rows[1]["ms"].ToString(), out m_Guanxian_end_ms); m_JiaoDian_ms = MapBasic.ComsStatic.getPointHeight(m_Guanxian_start, m_Guanxian_start_ms, m_Guanxian_end, m_Guanxian_end_ms, m_JiaoDian); //开始计算交点的地面高程 Double.TryParse(dsJSJDPT2Count.Rows[0]["dmgc"].ToString(), out m_Guanxian_start_gc); Double.TryParse(dsJSJDPT2Count.Rows[1]["dmgc"].ToString(), out m_Guanxian_end_gc); m_JiaoDian_gc = MapBasic.ComsStatic.getPointHeight(m_Guanxian_start, m_Guanxian_start_gc, m_Guanxian_end, m_Guanxian_end_gc, m_JiaoDian); //开始计算交点 之间的距离 第一个交点距离为0 if (m_JiaoDian_temp.X > 0 && m_JiaoDian_temp.Y > 0) { GeoLine geoline = new GeoLine(new Point2Ds { m_JiaoDian, m_JiaoDian_temp }); m_JiaoDian_jl = Math.Round(geoline.Length, 2); } m_JiaoDian_temp = m_JiaoDian; dr["dmgc"] = m_JiaoDian_gc; dr["gxgc"] = m_JiaoDian_gc - m_JiaoDian_ms; dr["gxms"] = m_JiaoDian_ms; dr["gxgj"] = m_Guanxian.GetFieldValue("gj"); dr["jl"] = m_JiaoDian_jl == 0 ? "" : m_JiaoDian_jl.ToString(); dr["gxSMID"] = m_Guanxian.GetFieldValue("smid"); dt.Rows.Add(dr); } m_Guanxian.MoveNext(); } if (dt.Rows.Count == m_Guanxian.RecordCount && dt.Rows.Count > 0) { DuanMianAnalystResult duanMianAnalystResult = new DuanMianAnalystResult(dt); duanMianAnalystResult.ShowDialog(); } else if (dt.Rows.Count < m_Guanxian.RecordCount) { Sunny.UI.UIMessageTip.ShowWarning(string.Format("应生成{0}个横切面,共生成{1}个横切面,请首先检查管线的起始点号和终点点号数据!", m_Guanxian.RecordCount, dt.Rows.Count), 5000); DuanMianAnalystResult duanMianAnalystResult = new DuanMianAnalystResult(dt); duanMianAnalystResult.ShowDialog(); this.CloseToolBar(); } else { Sunny.UI.UIMessageTip.ShowError("构建查询结果失败,请重新绘制断面", 5000); } } private void MapControl_Tracked(object sender, SuperMap.UI.TrackedEventArgs e) { m_TheLine = e.Geometry.Clone() as GeoLine; if (m_TheLine is null) return; m_TheLine.Style = new GeoStyle { LineColor = Color.Red, LineWidth = 1 }; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.TrackingLayer.Add(m_TheLine, "StartDraw"); m_Guanxian = ComsStatic.dvJSLK.Query(m_TheLine, 0, CursorType.Static); if (m_Guanxian.RecordCount < 1) { Sunny.UI.UIMessageTip.ShowError("当前断面没有管线信息,请重新绘制断面!至少2个断面才可以展示", 2000); } else { Sunny.UI.UIMessageTip.ShowOk("当前断面筛选到" + m_Guanxian.RecordCount + "条管线信息,需要生成个" + m_Guanxian.RecordCount + "横切面", 2000); } } private void StartDrawToolStripButton_Click(object sender, EventArgs e) { MapControl.Map.TrackingLayer.Clear(); MapControl.Action = SuperMap.UI.Action.CreateLine; MapControl.Tracked += MapControl_Tracked; } public override void AfterClose() { ComsStatic.RecordsetDispose(m_Guanxian); MapControl.Tracked -= MapControl_Tracked; base.AfterClose(); } private void InitializeComponent() { this.SuspendLayout(); // // DuanMian // this.Name = "DuanMian"; this.ResumeLayout(false); this.PerformLayout(); } } }