예제 #1
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
 void comboBoxCoordinateSystem_SelectedValueChanged(object sender, EventArgs e)
 {
     this.m_CurrentSpheroid = (Spheroid)int.Parse(this.comboBoxCoordinateSystem.SelectedValue.ToString());
     this.m_CoordHelper     = CoordinateFactory.CreateCoordinate(this.m_CurrentSpheroid);
     this.labela.Text       = this.m_CoordHelper.a.ToString();
     this.labelb.Text       = this.m_CoordHelper.b.ToString();
 }
예제 #2
0
        public static void Gps84_To_Point(double lat, double lng, out double x, out double y)
        {
            ICoordinate ic = CoordinateFactory.CreateCoordinate(Spheroid.WGS84);

            ic.Longitude0 = Convert.ToInt32(lng);
            ic.GaussPrjCalculate(lng, lat, out x, out y);
        }
예제 #3
0
 public static Coordinate TranslateNorthEast(this Coordinate coordinate)
 {
     if (coordinate == null)
     {
         return(null);
     }
     return(CoordinateFactory.CreateCoordinateFromRowAndColumn(coordinate.Row - 1, coordinate.Column + 1));
 }
예제 #4
0
 public static Coordinate TranslateSouthWest(this Coordinate coordinate)
 {
     if (coordinate == null)
     {
         return(null);
     }
     return(CoordinateFactory.CreateCoordinateFromRowAndColumn(coordinate.Row + 1, coordinate.Column - 1));
 }
예제 #5
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
 public frmMain()
 {
     InitializeComponent();
     InitConfig();
     this.m_CoordHelper = CoordinateFactory.CreateCoordinate(this.m_CurrentSpheroid);
     this.labela.Text   = this.m_CoordHelper.a.ToString();
     this.labelb.Text   = this.m_CoordHelper.b.ToString();
     SayVersion();
 }
예제 #6
0
        public void Create_WhenInvoked_CallsRandomDoubleGeneratorFourTimes()
        {
            // Arrange
            var a1      = 1000;
            var a2      = 100;
            var a3      = 10;
            var a4      = 1;
            var subject = new CoordinateFactory(rdnGeneratorMock.Object, a1, a2, a3, a4);

            // Act
            subject.Create();

            // Assert
            rdnGeneratorMock.Verify(r => r.GenerateInt(It.IsAny <int>()), Times.Exactly(4));
            rdnGeneratorMock.Verify(r => r.GenerateInt(a1), Times.Exactly(1));
            rdnGeneratorMock.Verify(r => r.GenerateInt(a2), Times.Exactly(1));
            rdnGeneratorMock.Verify(r => r.GenerateInt(a3), Times.Exactly(1));
            rdnGeneratorMock.Verify(r => r.GenerateInt(a4), Times.Exactly(1));
        }
예제 #7
0
파일: frmMain.cs 프로젝트: xuyongmin/esri
        private void buttonExportTFHCoord_Click(object sender, EventArgs e)
        {
            this.m_CurrentSpheroid = (Spheroid)int.Parse(this.comboBoxCoordinateSystem.SelectedValue.ToString());
            this.m_CoordHelper     = CoordinateFactory.CreateCoordinate(this.m_CurrentSpheroid);

            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Filter           = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            saveDialog.FilterIndex      = 1;
            saveDialog.RestoreDirectory = true;
            if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string fileName = saveDialog.FileName;
                Stream fs       = saveDialog.OpenFile();
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    List <string> xyList = new List <string>();
                    foreach (TFHObject obj in this.m_AllTFHS)
                    {
                        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]);

                            double  ltYe, ltXn, rbYe, rbXn;
                            LonWide lw    = (LonWide)int.Parse(this.comboBoxLonWide.SelectedValue.ToString());
                            int     delno = int.Parse(this.textBoxDELNO.Text.Trim());
                            this.m_CoordHelper.GaussPrjCalculate(ltl, ltb, lw, delno, out ltYe, out ltXn);
                            this.m_CoordHelper.GaussPrjCalculate(rbl, rbb, lw, delno, out rbYe, out rbXn);
                            string lbinfo  = string.Format("{0} {1} {2} {3}", ltl, ltb, rbl, rbb);
                            string xyinfo  = string.Format("{0} {1} {2} {3}", ltYe, ltXn, rbYe, rbXn);
                            string tfhinfo = string.Format("{0},{1},{2}", obj.TFH, lbinfo, xyinfo);
                            sw.WriteLine(tfhinfo);
                        }
                    }
                }
            }
        }
예제 #8
0
        public IGeometry ToGeometry(IExtents envelopeInternal)
        {
            ICoordinate[] verticies = new ICoordinate[5];

            ICoordinate min = envelopeInternal.Min;
            ICoordinate max = envelopeInternal.Max;

            verticies[0] = max;
            verticies[1] = CoordinateFactory.Create(min[Ordinates.X], max[Ordinates.Y]);
            verticies[2] = min;
            verticies[3] = CoordinateFactory.Create(max[Ordinates.X], min[Ordinates.Y]);
            verticies[4] = max;

            LinearRing ring = new LinearRing(verticies);

            ring.Factory = this;
            Polygon p = new Polygon(ring);

            p.Factory = this;
            return(p);
        }
예제 #9
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);
                    }
                }
            }
        }
예제 #10
0
 public static Coordinate GetCoordinateOfSquare(this Board board, Square square)
 {
     return(CoordinateFactory.CreateCoordinateFromIndex(board.GetIndexOfSquare(square)));
 }