美文网首页
高德坐标转换百度坐标

高德坐标转换百度坐标

作者: lunaSun | 来源:发表于2017-03-16 14:47 被阅读52次
func BD09FromGCJ02(_ coor:CLLocationCoordinate2D) ->CLLocationCoordinate2D{
  let x_pi = 3.14159265358979324*3000.0/180.0

  let x = coor.longitude, y = coor.latitude

  let z = sqrt(x * x + y * y) +0.00002*sin(y * x_pi)

  let theta = atan2(y, x) +0.000003*cos(x * x_pi)

  let bd_lon = z * cos(theta) + 0.0065

  let bd_lat = z * sin(theta) + 0.006

  return CLLocationCoordinate2D(latitude: bd_lat, longitude: bd_lon)

}

相关文章

网友评论

      本文标题:高德坐标转换百度坐标

      本文链接:https://www.haomeiwen.com/subject/wohjnttx.html