Skip to content

Instantly share code, notes, and snippets.

@nanmu42
Created August 21, 2019 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanmu42/2876591c49cc51e50fa71fa92fd540eb to your computer and use it in GitHub Desktop.
Save nanmu42/2876591c49cc51e50fa71fa92fd540eb to your computer and use it in GitHub Desktop.
计算从 (lon0, lat0) 经纬度(单位 °)移动 dx, dy 米后的新的经纬度
// geoOffset 计算从 (lon0, lat0) 经纬度(单位 °)移动 dx, dy 米后的新的经纬度
//
// 这个算法在100km以内有良好精度。
//
// source: https://stackoverflow.com/questions/2839533/adding-distance-to-a-gps-coordinate
func geoOffset(lon0, lat0, dx, dy float64) (lon, lat float64) {
lon = lon0 + (180/math.Pi)*(dx/6378137)/math.Cos(lat0/180*math.Pi)
lat = lat0 + (180/math.Pi)*(dy/6378137)
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment