Skip to content

Calculate geographical distances using the Haversine and Vincenty methods in Go

License

Notifications You must be signed in to change notification settings

asmarques/geodist

Repository files navigation

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

About

Calculate geographical distances using the Haversine and Vincenty methods in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages