地球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
0 条评论