百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

geodist

> 编程语言
开源

Golang 包,用于计算两个地理纬度、经度坐标之间的距离

192 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Golang 包,用于计算两个地理纬度、经度坐标之间的距离

geodist

GoLang package to compute the distance between two geographic latitude, longitude coordinates

Algorithm Comparison

  • Vincenty is more accurate than Haversine because is considers the Earth's ellipticity when performing the calculation, but takes a longer time to compute.
  • Wikipedia: Haversine
  • Wikipedia: Vincenty
  • Is the Haversine Formula or the Vincenty's Formula better for calculating distance?

Example

  • example.go
go
	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)

Online Calculators

  • Great Circle: NOAA: Latitude/Longitude Distance Calculator
  • Haversine: Moveable Type: Calculate distance, bearing and more between Latitude/Longitude points
  • Vincenty: CQSRG: WGS-84 World Geodetic System Distance Calculator

Acknowledgements

  • Haversine Algorithm in GoLang
  • Vincenty Algorithm in JavaScript

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Godistancegeolocationgogolang

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言