Newer
Older
GHFX_REFACTOR / Forms / FrmAddPipelineCoordinate.cs
wxn on 9 Nov 2016 1 KB 冗余代码整理
using System;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using GeoScene.Data;

namespace PipeLine.Forms
{
    public partial class FrmAddPipelineCoordinate : Office2007Form
    {
        public FrmAddPipelineCoordinate()
        {
            InitializeComponent();
        }

        public GSOGeoPolyline3D polyline;
        private void btnOK_Click(object sender, EventArgs e)
        {
            // 新建管线
            polyline = new GSOGeoPolyline3D();


            //把管线的段点坐标设置好
            GSOPoint3ds pts = new GSOPoint3ds();
            pts.Add(CreatePoint(txtX1.Text,txtY1.Text));
            pts.Add(CreatePoint(txtX2.Text,txtY2.Text));
            polyline.AddPart(pts);



            DialogResult = DialogResult.OK;
            Close();            
        }

        private GSOPoint3d CreatePoint(string _x, string _y)
        {
            int id = GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs");
     
            double x = Convert.ToDouble(_x);
            double y = Convert.ToDouble(_y);
            GSOPoint2d pt2d = new GSOPoint2d(x, y);
            GSOPoint2d result = GSOProjectManager.Inverse(pt2d, id);
           // double z = Convert.ToDouble(_z);
            GSOPoint3d pt3d = new GSOPoint3d(result.X, result.Y, 0);
            return pt3d;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }                
    }
}