| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- 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 = "断面分析";
- InitializeComponent();
- var analystToolStripButton = new ToolStripButton()
- {
- DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
- Text = "开始分析",
- Name = "Analyst",
- AutoToolTip = false
- };
- base.ToolStrip.Items.Add(analystToolStripButton);
- analystToolStripButton.Click += AnalystToolStripButton_Click;
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.CreateLine;
- MapControl.Tracked += MapControl_Tracked;
- }
- private void AnalystToolStripButton_Click(object sender, EventArgs e)
- {
- if (m_TheLine is null || m_TheLine.PartCount != 1) { Sunny.UI.UIMessageTip.ShowError("构建查询结果失败,请重新绘制断面"); return; }
- DataTable dt = new DataTable { TableName = "DuanMianAnalystResult" };
- dt.Columns.Add(new DataColumn { ColumnName = "dmgc", Caption = "地面高程(M)", DataType = Type.GetType("System.Double") });
- dt.Columns.Add(new DataColumn { ColumnName = "gxgc", Caption = "管线高程(M)", DataType = Type.GetType("System.Double") });
- dt.Columns.Add(new DataColumn { ColumnName = "gxms", Caption = "管线埋深(M)", DataType = Type.GetType("System.Double") });
- dt.Columns.Add(new DataColumn { ColumnName = "gxgj", Caption = "管线管径(MM)", DataType = Type.GetType("System.Int32") });
- dt.Columns.Add(new DataColumn { ColumnName = "gxSMID", Caption = "管线ID", /*DataType = Type.GetType("System.Int32")*/ });
- dt.Columns.Add(new DataColumn { ColumnName = "jl", Caption = "距离(M)", DataType = Type.GetType("System.Double") });
- dt.Columns.Add(new DataColumn { ColumnName = "x", Caption = "X坐标", DataType = Type.GetType("System.Double") });
- dt.Columns.Add(new DataColumn { ColumnName = "y", Caption = "Y坐标", DataType = Type.GetType("System.Double") });
- dt.Columns.Add(new DataColumn { ColumnName = "xLeft", Caption = "X坐标向左偏移", DataType = Type.GetType("System.Double") });
- 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(0, 0);
- 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;
- while (!m_Guanxian.IsEOF)
- {
- dr = dt.NewRow();
- dsJSJDPT2Count = ComsStatic.QueryDataTable(ComsStatic.gsGuanDian, string.Format(" bsm ='{0}' OR bsm='{1}' ", m_Guanxian.GetFieldValue("qsdh"), m_Guanxian.GetFieldValue("zddh")));
- if (dsJSJDPT2Count.Rows.Count == 2)//理论上只会查询到2条记录,分别是管线的起点标识码和终点标识码
- {
- //获得管线的 起点坐标 起始埋深 终点坐标 终点埋深 来自管点gsGuanDian数据
- m_Guanxian_start = getPoint2D(dsJSJDPT2Count.Rows[0]["x"], dsJSJDPT2Count.Rows[0]["y"]);
- m_Guanxian_end = getPoint2D(dsJSJDPT2Count.Rows[1]["x"], dsJSJDPT2Count.Rows[1]["y"]);
- 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 = 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 = 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;//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)
- {
- AnalystResultPouDuanMian form = new AnalystResultPouDuanMian(dt, "duanmian");
- form.ShowDialog();
- CloseToolBar();
- }
- //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("构建查询结果失败,请重新绘制断面");
- }
- }
- private static Point2D getPoint2D(object x, object y)
- {
- return new Point2D(ComsStatic.StringToDouble(x), ComsStatic.StringToDouble(y));
- }
- 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 = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
- MapControl.Map.TrackingLayer.Clear();
- MapControl.Map.TrackingLayer.Add(m_TheLine, "StartDraw");
- MapControl.Map.RefreshTrackingLayer();
- m_Guanxian = ComsStatic.gsGuanXian.Query(m_TheLine, 0, " enabled=1 and qsdh is not null and zddh is not null ", CursorType.Static);
- if (m_Guanxian.RecordCount < 1)
- {
- Sunny.UI.UIMessageTip.ShowError("当前横断面没有管线信息,请重新绘制!");
- }
- else
- {
- Sunny.UI.UIMessageTip.ShowOk("当前横断面需要生成" + m_Guanxian.RecordCount + "个管线横切面");
- }
- }
- 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();
- }
- }
- }
|