Skip to content

JamesLMilner/cheap-ruler-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cheapruler (Go)

godoc reference

"A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.

The approximations are based on an FCC-approved formula of ellipsoidal Earth projection. For distances under 500 kilometers and not on the poles, the results are very precise β€” within 0.1% margin of error compared to Vincenti formulas, and usually much less for shorter distances."

Usage

Here is an example of doing a distance measurement in kilometers, with a ruler Latitude of 32.8351:

cr, _ := NewCheapruler(32.8351, "kilometers")
pointA := []float64{-96.920341, 32.838261}
pointB := []float64{-96.920421, 32.838295}
dist := cr.Distance(pointA, pointB)
fmt.Println(dist)
// Output: 0.008385790760648736

Acknowledgements

Based on Vladimir Agafonkin's JavaScript library cheapruler

License

ISC License