Golang 包,用于计算两个地理纬度、经度坐标之间的距离
GoLang package to compute the distance between two geographic latitude, longitude coordinates
Vincenty is more accurate than Haversine because is considers the Earth's ellipticity when performing the calculation, but takes a longer time to compute. var newYork = geodist.Coord{Lat: 40.7128, Lon: 74.0060}
var sanDiego = geodist.Coord{Lat: 32.7157, Lon: 117.1611}
miles, km, ok := geodist.VincentyDistance(newYork, sanDiego)
if !ok {
fmt.Println("Unable to compute Vincenty Distance.")
return
}
fmt.Printf(" [Vincenty] New York to San Diego: %.3f m, %.3f km\n", miles, km)
var elPaso = geodist.Coord{Lat: 31.7619, Lon: 106.4850}
var stLouis = geodist.Coord{Lat: 38.6270, Lon: 90.1994}
miles, km = geodist.HaversineDistance(elPaso, stLouis)
fmt.Printf("[Haversine] El Paso to St. Louis: %.3f m, %.3f km\n", miles, km)GoLangJavaScript暂无开放 Issues,或尚未同步最近议题。