mapguide坐标转换

来源:互联网 发布:中国数据研究中心 编辑:程序博客网 时间:2024/05/22 09:43
  //转换坐标系(把经纬度转换为西安80 117)
        private void ConvertXY(DataTable PTable)
        {

            int i;

            //获取地图投影

            MgCoordinateSystemFactory AcoordinateSystemFactory = new MgCoordinateSystemFactory();

           //西安80坐标系

            MgCoordinateSystem AcoordSystemXIAN80 = AcoordinateSystemFactory.Create(AcoordinateSystemFactory.ConvertEpsgCodeToWkt(2384));

          //wgs84坐标系

            MgCoordinateSystem AcoordSystemWGS84 = AcoordinateSystemFactory.Create(AcoordinateSystemFactory.ConvertEpsgCodeToWkt(4326));

          //转换

            MgCoordinateSystemTransform AcoordTransform = AcoordinateSystemFactory.GetTransform(AcoordSystemWGS84, AcoordSystemXIAN80);

            MgCoordinate AnewCoord;

            for (i = 0; i < PTable.Rows.Count; i++)
            {
                AnewCoord = AcoordTransform.Transform(Convert.ToDouble(PTable.Rows[i]["dnE"].ToString()), Convert.ToDouble(PTable.Rows[i]["dnNorth"].ToString()));

                PTable.Rows[i]["x"] = AnewCoord.X;
                PTable.Rows[i]["y"] = AnewCoord.Y;
            }


        }
原创粉丝点击