python 经纬度墨卡托互转

墨卡托转经纬度

	# 墨卡托转经纬度
	def marcator2lonlat(x,y):
        lonlat = {}
        xx = x/ 20037508.3427892 * 180
        yy = y/ 20037508.3427892 * 180
        lonlat['x'] = xx
        lonlat['y'] = 180 / math.pi * (2 * math.atan(math.exp(yy * math.pi / 180)) - math.pi / 2)
        return lonlat

    # 经纬度转墨卡托
    def lonlat2marcator(x,y):
        marcator = {}
        xx = x/180*20037508.3427892
        yy = math.log(math.tan((90 + y) * math.pi / 360))/(math.pi / 180)
        marcator['x'] = xx
        marcator['y'] = yy * 20037508.34 / 180
        return marcator