vector.go 602 B

12345678910111213141516171819
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package util
  4. import "math"
  5. // GeoBaidu2Gaode 将百度转为高德的经纬度坐标
  6. // 输入:百度的纬经度, 纬度lat,经度lon
  7. // 输出:高德的纬经度, 纬度,经度
  8. func GeoBaidu2Gaode(lat float64, lon float64) (float64, float64) {
  9. PI := 3.14159265358979324 * 3000.0 / 180.0
  10. x := lon - 0.0065
  11. y := lat - 0.006
  12. z := math.Sqrt(x*x+y*y) - 0.00002*math.Sin(y*PI)
  13. theta := math.Atan2(y, x) - 0.000003*math.Cos(x*PI)
  14. return z * math.Sin(theta), z * math.Cos(theta)
  15. }