您的位置:首页 > 编程语言 > Python开发

python百度经纬度转google经纬度

2016-12-14 14:18 288 查看
因为公司项目需要遇到了这个问题。转完后几乎是完美的,本来打算用3方API的,一个月大概是600块,20W次,省钱了。

import math

class CoordinateConversion:
def __init__(self):
self.x_pi = 3.14159265358979324 * 3000.0 / 180.0
self.pi = 3.14159265358979324

def bd_google_encrypt(self,bd_lat,bd_lon):
item = []
x =  bd_lon - 0.0065
y = bd_lat - 0.006
z = math.sqrt(x * x + y * y) - 0.00002 * math.sin(y * self.x_pi)
theta = math.atan2(y, x) - 0.000003 * math.cos(x * self.x_pi)
gg_lon = z * math.cos(theta)
gg_lat = z * math.sin(theta)
item.append(gg_lon)
item.append(gg_lat)
return item

print  CoordinateConversion().bd_google_encrypt(113.823181406,40.2223115261)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: