Swift开发教程--火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转
class func bd_encrypt(gg_lat:Double,gg_lon: Double) -> (bd_lat:Double,bd_lon: Double) { var x = gg_lon; var y = gg_lat; var z =sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi); var theta =atan2(y,x) + 0.000003 * cos(x * x_pi); var bdlon = z *cos(theta) + 0.0065; var bdlat = z *sin(theta) + 0.006; return (bdlat,bdlon) }
classfunc bd_decrypt(bd_lat: Double,bd_lon:Double) -> (gg_lat: Double,gg_lon:Double) { var x = bd_lon - 0.0065; var y = bd_lat - 0.006; var z =sqrt(x * x + y * y) - 0.00002 * sin(y * x_pi); var theta =atan2(y,x) - 0.000003 * cos(x * x_pi); var gglon = z *cos(theta); var gglat = z *sin(theta); return (gglat,gglon) } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |