geo

package
v1.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EarthRadius       = 6371 * Kilometer
	DoubleEarthRadius = 2 * EarthRadius
	PiOver180         = math.Pi / 180
)

Constants needed for distance calculations

View Source
const (
	Millimeter = Distance(0.001)
	Centimeter = Distance(0.01)
	Meter      = Distance(1)
	Kilometer  = Distance(1000)
	Mile       = Distance(1 / MilesPerKilometer * 1000)
)

Standard length constants

View Source
const MilesPerKilometer = 0.6213712

MilesPerKilometer Constants for conversions

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinate

type Coordinate struct {
	Lat, Lng 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

func (d Distance) Centimeters() float64

Centimeters gets the number of total centimeters represented by the distance

func (Distance) Equals

func (d Distance) Equals(other, tolerance Distance) bool

func (Distance) Kilometers

func (d Distance) Kilometers() float64

Kilometers gets the number of total kilometers represented by the distance

func (Distance) Meters

func (d Distance) Meters() float64

Meters gets the number of total meters represented by the distance

func (Distance) Miles

func (d Distance) Miles() float64

Miles gets the number of total miles represented by the distance

func (Distance) Millimeters

func (d Distance) Millimeters() float64

Millimeters gets the number of total millimeters represented by the distance

func (Distance) String

func (d Distance) String() string

String implements Stringer and returns a formatted string representation of the distance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL