An assortment of geolocation related tools, all packaged in one easy to use kit. A direct port from http://github.com/MichaelSolati/geokit
Calculates the distance, in kilometers, between two coordinates.
start
and end
must be LatLng { Lat: 0, Lng: 0 }
.
start := &geokit.LatLng{Lat: 41.3083, Lng: -72.9279};
end := &geokit.LatLng{Lat: -33.8688, Lng: 151.2093};
distance, _ := geokit.Distance(location1, location2, nil); // distance == 16082.811206563834
Generates Geohash of coordinates.
coordinates
must be LatLng { Lat: 0, Lng: 0 }
.
coordinates := &geokit.LatLng{Lat: 41.3083, Lng: -72.9279};
hash, _ := geokit.Hash(coordinates, nil); // hash == 'drk4urzw2c'
Decodes a Geohash into its Latitude and Longitude as a LatLng.
hash := 'r3gx2f77b';
coordinates, _ := geokit.DecodeHash(hash); // coordinates === &geokit.LatLng{Lat: -33.86881113052368, Lng: 151.2093186378479}
Validates coordinates and returns a boolean if valid, or throws an error if invalid.
coordinates
must be LatLng { lat: 0, lng: 0 }
.
coordinates := &geokit.LatLng{Lat: 41.3083, Lng: -72.9279};
isValid, _ = geokit.ValidateCoordinates(coordinates); // true
Validates a Geohash and returns a boolean if valid, or throws an error if invalid.
hash := 'r3gx2f77b';
isValid = geokit.ValidateHash(hash); // true