工具包
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 2 години
преди 2 години
12345678910111213141516
  1. package zhios_tool_utils
  2. import "math"
  3. //返回单位为:千米
  4. func GetDistance(lat1, lat2, lng1, lng2 float64) float64 {
  5. radius := 6371000.0 //6378137.0
  6. rad := math.Pi / 180.0
  7. lat1 = lat1 * rad
  8. lng1 = lng1 * rad
  9. lat2 = lat2 * rad
  10. lng2 = lng2 * rad
  11. theta := lng2 - lng1
  12. dist := math.Acos(math.Sin(lat1)*math.Sin(lat2) + math.Cos(lat1)*math.Cos(lat2)*math.Cos(theta))
  13. return dist * radius / 1000
  14. }