java gps经纬度坐标转高德坐标_高德经纬度转普通GPS经纬度

# 官方API: http://lbs.amap.com/api/webservice/guide/api/convert

# 坐标体系说明:http://lbs.amap.com/faq/top/coordinate/3

# GCJ02->WGS84 Java版本:http://www.cnblogs.com/xinghuangroup/p/5787306.html

# 验证坐标转换正确性的地址:http://www.gpsspg.com/maps.htm

# 以下内容为原创,转载请注明出处。

import math

def GCJ2WGS(location):

# location格式如下:locations[1] = "113.923745,22.530824"

lon = float(location[0:location.find(",")])

lat = float(location[location.find(",") + 1:len(location)])

a = 6378245.0 # 克拉索夫斯基椭球参数长半轴a

ee = 0.00669342162296594323 #克拉索夫斯基椭球参数第一偏心率平方

PI = 3.14159265358979324 # 圆周率

# 以下为转换公式

x = lon - 105.0

y = lat - 35.0

# 经度

dLon = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * math.sqrt(abs(x));

dLon += (20.0 * math.sin(6.0 * x * PI) + 20.0 * math.sin(2.0 * x * PI)) * 2.0 / 3.0;

dLon += (20.0 * math.sin(x * PI) + 40.0 * math.sin(x / 3.0 * PI)) * 2.0 / 3.0;

dLon += (150.0 * math.sin(x / 12.0 * PI) + 300.0 * math.sin(x / 30.0 * PI)) * 2.0 / 3.0;

#纬度

dLat = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * math.sqrt(abs(x));

dLat += (20.0 * math.sin(6.0 * x * PI) + 20.0 * math.sin(2.0 * x * PI)) * 2.0 / 3.0;

dLat += (20.0 * math.sin(y * PI) + 40.0 * math.sin(y / 3.0 * PI)) * 2.0 / 3.0;

dLat += (160.0 * math.sin(y / 12.0 * PI) + 320 * math.sin(y * PI / 30.0)) * 2.0 / 3.0;

radLat = lat / 180.0 * PI

magic = math.sin(radLat)

magic = 1 - ee * magic * magic

sqrtMagic = math.sqrt(magic)

dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI);

dLon = (dLon * 180.0) / (a / sqrtMagic * math.cos(radLat) * PI);

wgsLon = lon - dLon

wgsLat = lat - dLat

return wgsLon,wgsLat

转载的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值