地球WGS-84 转 火星GCJ-02 转 百度BD-09
地球WGS-84: 29.1934702 119.465265
火星GCJ-02: 29.1908196 119.470341
百度 BD-09: 29.1965172 119.476936
百度BD-09 转 火星GCJ-02 转 地球WGS-84
百度 BD-09: 29.196518 119.476936
火星GCJ-02: 29.1908195 119.470342
地球WGS-84: 29.1934702 119.465265
china_shift.py
测试源码
# load dynamic C library for map shift
from ctypes import *
shift = cdll.LoadLibrary('./china_shift.so')
class Location(Structure):
_fields_ = [
('lon', c_double),
('lat', c_double)]
shift.transformFromWGSToGCJ.argtypes = [Location]
shift.transformFromWGSToGCJ.restype = Location
shift.transformFromGCJToWGS.argtypes = [Location]
shift.transformFromGCJToWGS.restype = Location
shift.bd_encrypt.argtypes = [Location]
shift.bd_encrypt.restype = Location
shift.bd_decrypt.argtypes = [Location]
shift.bd_decrypt.restype = Location
# Location gps = { 119.465265, 29.1934702};
# 地球WGS-84 转 火星GCJ-02 转 百度BD-09
loc = Location(lon = 119.465265, lat = 29.1934702)
print("地球WGS-84:",loc.lat, loc.lon)
loc = shift.transformFromWGSToGCJ(loc)
print("火星GCJ-02:",loc.lat, loc.lon)
loc = shift.bd_encrypt(loc)
print("百度 BD-09:",loc.lat, loc.lon)
# 百度BD-09 转 火星GCJ-02 转 地球WGS-84
loc = Location(lon = 119.476936, lat = 29.196518 )
print("百度 BD-09:",loc.lat, loc.lon)
loc = shift.bd_decrypt(loc)
print("火星GCJ-02:",loc.lat, loc.lon)
loc = shift.transformFromGCJToWGS(loc)
print("地球WGS-84:",loc.lat, loc.lon)
Gcc 编译 china_shift.so
转换坐标库命令 参考链接
gcc -shared -fPIC -o china_shift.so china_shift.c
相关推荐: 小蜜蜂微信公众号文章助手(BeePress)2.2.0最新
小蜜蜂微信公众号文章助手(BeePress)2.2.0最新 来源:未知日期:2019/12/03 21:34 浏览: 2.2.0 更新(没需要可不更新) 1.修复代理模式无法采集问题(macOS用户可能会遇到这个问题) win链接:https://shar…
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
请登录后发表评论
注册