Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.2 KB

README.md

File metadata and controls

34 lines (22 loc) · 1.2 KB

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