码迷,mamicode.com
首页 > 其他好文 > 详细

经纬度和墨卡托互相转换

时间:2014-08-23 16:37:31      阅读:819      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   div   log   new   sp   on   

 1 //经纬度转墨卡托
 2         public MapPoint lonLat2Mercator(MapPoint lonLat)
 3         {
 4             MapPoint mercator = new MapPoint();
 5             double x = lonLat.X * 20037508.34 / 180;
 6             double y = Math.Log(Math.Tan((90 + lonLat.Y) * Math.PI / 360)) / (Math.PI / 180);
 7             y = y * 20037508.34 / 180;
 8             mercator.X = x;
 9             mercator.Y = y;
10             return mercator;
11         }
12         //墨卡托转经纬度
13         public MapPoint Mercator2lonLat(MapPoint mercator)
14         {
15             MapPoint lonLat = new MapPoint();
16             double x = mercator.X / 20037508.34 * 180;
17             double y = mercator.Y / 20037508.34 * 180;
18             y = 180 / Math.PI * (2 * Math.Atan(Math.Exp(y * Math.PI / 180)) - Math.PI / 2);
19             lonLat.X = x;
20             lonLat.Y = y;
21             return lonLat;
22         }

From http://xuliduo.iteye.com/blog/1534475

经纬度和墨卡托互相转换

标签:style   blog   http   color   div   log   new   sp   on   

原文地址:http://www.cnblogs.com/JiNerd/p/3931323.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!