https://github.com/umahmood/haversine
Haversine is a Go library which implements the haversine formula.
https://github.com/umahmood/haversine
go golang haversine-formula
Last synced: 4 months ago
JSON representation
Haversine is a Go library which implements the haversine formula.
- Host: GitHub
- URL: https://github.com/umahmood/haversine
- Owner: umahmood
- License: mit
- Created: 2015-09-16T21:29:09.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-01-05T16:52:22.000Z (over 2 years ago)
- Last Synced: 2025-05-18T13:02:01.634Z (about 1 year ago)
- Topics: go, golang, haversine-formula
- Language: Go
- Size: 133 KB
- Stars: 78
- Watchers: 3
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/umahmood/haversine)
# Haversine
Package haversine is a Go library which implements the haversine formula. The
haversine formula gives great-circle distances between two points on a sphere
from their longitudes and latitudes. The sphere in this case is the surface of
the Earth.

*The dotted yellow line is an arc of a great circle. It gives the shortest
distance between the two yellow points. Image courtesy USGS.*
# Installation
> go get github.com/umahmood/haversine
> cd $GOPATH/src/github.com/umahmood/haversine/
> go test -v ./...
# Usage
The below example shows how to calculate the shortest path between two
coordinates on the surface of the Earth.
package main
import (
"fmt"
"github.com/umahmood/haversine"
)
func main() {
oxford := haversine.Coord{Lat: 51.45, Lon: 1.15} // Oxford, UK
turin := haversine.Coord{Lat: 45.04, Lon: 7.42} // Turin, Italy
mi, km := haversine.Distance(oxford, turin)
fmt.Println("Miles:", mi, "Kilometers:", km)
}
# Documenation
> http://godoc.org/github.com/umahmood/haversine
# References
* https://plus.maths.org/content/lost-lovely-haversine
* https://en.wikipedia.org/wiki/Haversine_formula
# License
See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).