1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 火星坐标系和百度坐标系的经纬度相互转换

火星坐标系和百度坐标系的经纬度相互转换

时间:2021-04-27 15:08:05

相关推荐

火星坐标系和百度坐标系的经纬度相互转换

微信小程序和支付宝小程序的map组件的坐标都是火星坐标系

/*** 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法将 GCJ-02 坐标转换成 BD-09 坐标** @param gg_lat* @param gg_lon*/gcj02_To_Bd09(gg_lat, gg_lon) {const x_PI = 3.14159265358979324 * 3000.0 / 180.0const z = Math.sqrt(gg_lon * gg_lon + gg_lat * gg_lat) + 0.00002 * Math.sin(gg_lat * x_PI)const theta = Math.atan2(gg_lat, gg_lon) + 0.000003 * Math.cos(gg_lon * x_PI)const bd_lng = z * Math.cos(theta) + 0.0065const bd_lat = z * Math.sin(theta) + 0.006return {latitude: bd_lat,longitude: bd_lng}}/*** 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02) 的转换算法* @param bd_lat* @param bd_lon* @returns {{latitude: number, longitude: number}}*/bd09_To_Gcj02(bd_lat, bd_lon) {const x_PI = 3.14159265358979324 * 3000.0 / 180.0const x = bd_lon - 0.0065const y = bd_lat - 0.006const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI)const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI)const gg_lng = z * Math.cos(theta)const gg_lat = z * Math.sin(theta)return {latitude: gg_lat,longitude: gg_lng}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。