Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

distance

CircleCI

Using the Haversine formula to calculate the great-circle distance between 2 points.

Installation

go get -u github.com/ehis/distance

Usage

  • distance.GreatCircle() - returns the great-circle distance between 2 points.
// []float64{longitude, latitude}
pt1 := []float64{-180, 40.71427}
pt2 := []float64{180, 40.71427}

d := distance.GreatCircle(pt1, pt2) 
  • distance.PointSegment() - return the distance between a point and the closest point on a line segment.
// []float64{x, y}
pt := []float64{3, 2}
pt1 := []float64{-2, 1}
pt2 := []float64{5, 3}
d := distance.PointSegment(pt, pt1, pt2)

Inspiration from distance - an elixir library

About

Go lib to calculate distance 🗺

Topics

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages