Skip to content

Haversine is a Go library which implements the haversine formula.

License

Notifications You must be signed in to change notification settings

umahmood/haversine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

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.

Earth great circle

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

License

See the LICENSE file for license rights and limitations (MIT).

About

Haversine is a Go library which implements the haversine formula.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages