Created
August 21, 2019 08:28
-
-
Save nanmu42/2876591c49cc51e50fa71fa92fd540eb to your computer and use it in GitHub Desktop.
计算从 (lon0, lat0) 经纬度(单位 °)移动 dx, dy 米后的新的经纬度
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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