Documentation ¶
Index ¶
Constants ¶
const ( EarthRadius = 6371 * Kilometer DoubleEarthRadius = 2 * EarthRadius PiOver180 = math.Pi / 180 )
Constants needed for distance calculations
const ( Millimeter = Distance(0.001) Centimeter = Distance(0.01) Meter = Distance(1) Kilometer = Distance(1000) Mile = Distance(1 / MilesPerKilometer * 1000) )
Standard length constants
const MilesPerKilometer = 0.6213712
Constants for conversions
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinate ¶
type Coordinate struct {
Latitude, Longitude float64
}
Coordinate represents a specific location on Earth
func (Coordinate) DistanceTo ¶
func (c Coordinate) DistanceTo(other Coordinate) Distance
DistanceTo calculates the distance from this coordinate to another coordinate
func (Coordinate) String ¶
func (c Coordinate) String() string
String implements Stringer, returns a string representation of the coordinate
type Distance ¶
type Distance float64
Distance represents a spacial distance. Fundamentally, the underlying float64 represents the raw number of meters
func DistanceBetween ¶
func DistanceBetween(a, b Coordinate) Distance
DistanceBetween calculates the distance between two coordinates
func (Distance) Centimeters ¶
Meters gets the number of total centimeters represented by the distance
func (Distance) Kilometers ¶
Kilometers gets the number of total kilometers represented by the distance
func (Distance) Millimeters ¶
Meters gets the number of total millimeters represented by the distance