GeoGopher
is a Go package for performing geographic distance calculations between points on Earth. It offers flexibility in units of measurement, including kilometers, meters, miles, yards, feet, and nautical miles, and allows for calculations using a customizable Earth radius.
- Calculate distances between two geographical points.
- Support for various units of distance (kilometers, meters, miles, yards, feet, nautical miles).
- Optional parameters for calculations, such as using a different Earth radius.
To install GeoGopher
, use the following command:
go get github.com/apspan/geogopher
To use GeoGopher, import it into your Go project:
import "<github.com/apspan/geogopher>"
Here's a simple example of calculating the distance between two points on Earth:
package main
import (
"fmt"
"github.com/apspan/geogopher"
)
func main() {
// Define two locations
loc1 := GeoGopher.NewCoordinates(40.7128, -74.0060) // New York City
loc2 := GeoGopher.NewCoordinates(51.5074, -0.1278) // London
// Calculate the distance
distance := GeoGopher.CalculateDistanceOnEarth(loc1, loc2)
fmt.Printf("Distance: %f kilometers\n", distance.Kilometers())
}
Contributions are welcome! Please feel free to submit pull requests or open issues to improve the package.
This package is licensed under the MIT License - see the LICENSE file for details.