예제 #1
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        /// <summary>
        /// 经纬度转图幅号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLBToTFH_Click(object sender, EventArgs e)
        {
            MapScaleObject obj = this.comboBoxMapScale.SelectedItem as MapScaleObject;

            if (obj != null)
            {
                double L   = 0; double.TryParse(this.textBoxToTFHL.Text.Trim(), out L);
                double B   = 0; double.TryParse(this.textBoxToTFHB.Text.Trim(), out B);
                string tfh = TFHHelper.GetTFH(L, B, obj);
                this.textBoxTFH.Text = tfh;
            }
        }
예제 #2
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        /// <summary>
        /// 图幅号经纬度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonTFHToLB_Click(object sender, EventArgs e)
        {
            MapScaleObject scaleObj = null;
            double         LTL, LTB, RBL, RBB;
            string         tfh = this.textBoxTFH.Text.Trim();

            TFHHelper.GetLTRBPoints(tfh, out scaleObj, out LTL, out LTB, out RBL, out RBB);
            if (scaleObj != null)
            {
                MessageBox.Show(string.Format("比例尺:{0}  LTL:{1}  LTB:{2}  RBL:{3}  RBB:{4}", scaleObj.Label, LTL.ToString(), LTB.ToString(), RBL.ToString(), RBB.ToString()));
            }
            else
            {
                MessageBox.Show(string.Format("图幅号[{0}]无法解析!", tfh));
            }
        }
예제 #3
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        private void buttonLTBRTFH_Click(object sender, EventArgs e)
        {
            MapScaleObject obj = this.comboBoxLTRBMapScale.SelectedItem as MapScaleObject;

            if (obj != null)
            {
                double ltl, ltb, rbl, rbb;
                double.TryParse(this.textBoxLTL.Text.Trim(), out ltl);
                double.TryParse(this.textBoxLTB.Text.Trim(), out ltb);
                double.TryParse(this.textBoxRBL.Text.Trim(), out rbl);
                double.TryParse(this.textBoxRBB.Text.Trim(), out rbb);
                string ltTFH = TFHHelper.GetTFH(ltl, ltb, obj);
                string rbTFH = TFHHelper.GetTFH(rbl, rbb, obj);
                this.textBoxLTTFH.Text = ltTFH;
                this.textBoxRBTFH.Text = rbTFH;
            }
        }
예제 #4
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        private void buttonLTRBPointToTFHs_Click(object sender, EventArgs e)
        {
            MapScaleObject obj = this.comboBoxLTRBMapScale.SelectedItem as MapScaleObject;

            this.m_AllTFHS = new List <TFHObject>();
            if (obj != null)
            {
                string ltTFH, rbTFH;
                ltTFH = this.textBoxLTTFH.Text.Trim();
                rbTFH = this.textBoxRBTFH.Text.Trim();
                string msg = string.Empty;
                this.m_AllTFHS = TFHHelper.GetTFHList(ltTFH, rbTFH, out msg);
                this.checkedListBoxLTRBTFHs.DataSource    = null;
                this.checkedListBoxLTRBTFHs.DataSource    = this.m_AllTFHS;
                this.checkedListBoxLTRBTFHs.DisplayMember = "TFH";
                this.checkedListBoxLTRBTFHs.ValueMember   = "TFH";
            }
        }
예제 #5
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        /// <summary>
        /// 导出所有图幅号到shape文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonTFHExportShp_Click(object sender, EventArgs e)
        {
            MapScaleObject scaleObj   = this.comboBoxLTRBMapScale.SelectedItem as MapScaleObject;
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Filter           = "Shape文件(*.shp)|*.*|所有文件(*.*)|*.*";
            saveDialog.FilterIndex      = 1;
            saveDialog.RestoreDirectory = true;
            saveDialog.FileName         = "LB-" + scaleObj.Scale.ToString();
            if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string        fileName = saveDialog.FileName;
                List <string> xyList   = new List <string>();
                foreach (TFHObject obj in this.checkedListBoxLTRBTFHs.Items)
                {
                    string   xy  = string.Empty;
                    string[] xys = obj.Extent.Split(',');
                    if (xys.Length == 4)
                    {
                        double ltl = double.Parse(xys[0]);
                        double ltb = double.Parse(xys[1]);
                        double rbl = double.Parse(xys[2]);
                        double rbb = double.Parse(xys[3]);

                        xy += string.Format("{0},", obj.TFH);
                        xy += string.Format("{0} {1},", ltl, rbb);
                        xy += string.Format("{0} {1},", ltl, ltb);
                        xy += string.Format("{0} {1},", rbl, ltb);
                        xy += string.Format("{0} {1},", rbl, rbb);
                        xy += string.Format("{0} {1}", ltl, rbb);
                        xyList.Add(xy);
                    }
                }

                try
                {
                    ShapeUtility.ExportShapeFile(fileName, xyList);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #6
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        private void buttonExportXYTFHShape_Click(object sender, EventArgs e)
        {
            if (this.m_AllTFHS.Count > 0)
            {
                this.m_CurrentSpheroid = (Spheroid)int.Parse(this.comboBoxCoordinateSystem.SelectedValue.ToString());
                this.m_CoordHelper     = CoordinateFactory.CreateCoordinate(this.m_CurrentSpheroid);
                MapScaleObject scaleObj = this.comboBoxLTRBMapScale.SelectedItem as MapScaleObject;

                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.Filter           = "Shape文件(*.shp)|*.*|所有文件(*.*)|*.*";
                saveDialog.FilterIndex      = 1;
                saveDialog.RestoreDirectory = true;
                saveDialog.FileName         = "XY-" + scaleObj.Scale.ToString();
                if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string        fileName = saveDialog.FileName;
                    List <string> xyList   = new List <string>();
                    //获取第一个和最后一格
                    TFHObject firstTFHObj = null;
                    TFHObject endTFHObj   = null;
                    int       tmpHs       = 0;
                    int       tmpLs       = 0;
                    firstTFHObj = this.m_AllTFHS[0];
                    endTFHObj   = this.m_AllTFHS[this.m_AllTFHS.Count - 1];
                    for (int i = 0; i < this.m_AllTFHS.Count; i++)
                    {
                        if (this.m_AllTFHS[i].H1 == firstTFHObj.H1)
                        {
                            tmpLs++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    tmpHs = this.m_AllTFHS.Count / tmpLs;

                    double   ltYe, ltXn, rbYe, rbXn;
                    LonWide  lw         = (LonWide)int.Parse(this.comboBoxLonWide.SelectedValue.ToString());
                    int      delno      = int.Parse(this.textBoxDELNO.Text.Trim());
                    string[] firstTLXYs = firstTFHObj.Extent.Split(',');
                    string[] endRBXYs   = endTFHObj.Extent.Split(',');
                    double   ltl        = double.Parse(firstTLXYs[0]);
                    double   ltb        = double.Parse(firstTLXYs[1]);
                    double   rbl        = double.Parse(endRBXYs[2]);
                    double   rbb        = double.Parse(endRBXYs[3]);
                    this.m_CoordHelper.GaussPrjCalculate(ltl, ltb, lw, delno, out ltYe, out ltXn);
                    this.m_CoordHelper.GaussPrjCalculate(rbl, rbb, lw, delno, out rbYe, out rbXn);
                    double rXn = 0, rYe = 0;
                    rXn = Math.Abs((ltXn - rbXn) / tmpHs);
                    rYe = Math.Abs((rbYe - ltYe) / tmpLs);

                    for (int i = 0; i < this.m_AllTFHS.Count; i++)
                    {
                        double tmpLTYe = 0, tmpLTXn = 0, tmpRBYe = 0, tmpRBXn = 0;
                        int    tmpH = (int)(Math.Floor((double)(i / tmpLs)));
                        int    tmpL = (int)(i % tmpLs);
                        string xy   = string.Empty;

                        tmpLTYe = ltYe + rYe * tmpL;
                        tmpLTXn = ltXn - rXn * tmpH;
                        tmpRBYe = ltYe + rYe * (tmpL + 1);
                        tmpRBXn = ltXn - rXn * (tmpH + 1);

                        xy += string.Format("{0},", this.m_AllTFHS[i].TFH);
                        xy += string.Format("{0} {1},", tmpLTYe, tmpRBXn);
                        xy += string.Format("{0} {1},", tmpLTYe, tmpLTXn);
                        xy += string.Format("{0} {1},", tmpRBYe, tmpLTXn);
                        xy += string.Format("{0} {1},", tmpRBYe, tmpRBXn);
                        xy += string.Format("{0} {1}", tmpLTYe, tmpRBXn);
                        xyList.Add(xy);
                    }
                    try
                    {
                        ShapeUtility.ExportShapeFile(fileName, xyList);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }