/geodist

Calculate geographical distances using the Haversine and Vincenty methods in Go

Primary LanguageGoMIT LicenseMIT

geodist

Go Reference Build Status

Implementation of the Haversine and Vincenty methods in Go for calculating geographical distances between points on the surface of the Earth.

Installation

go get github.com/asmarques/geodist

Usage

package main

import (
	"fmt"
	"github.com/asmarques/geodist"
)

func main() {
	lis := geodist.Point{38.781311, -9.135918}
	sfo := geodist.Point{37.618817, -122.375427}

	d := geodist.HaversineDistance(lis, sfo)
	fmt.Printf("Haversine: %.2f km\n", d)

	d, err := geodist.VincentyDistance(lis, sfo)
	if err != nil {
		fmt.Printf("Failed to converge: %v", err)
	}

	fmt.Printf("Vincenty: %.6f km\n", d)
}

License

MIT