# \[ANN\] geodesic 1.0.0 released

**URL:** <https://www.ruby-forum.com/t/ann-geodesic-1-0-0-released/173687>\
**Category:** Ruby\
**Created:** [August 13, 2009, 10:34am UTC](https://www.ruby-forum.com/t/ann-geodesic-1-0-0-released/173687 "2009-08-13T10:34:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kookjr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/df788c/32.png) [@kookjr](https://www.ruby-forum.com/u/kookjr)\
**Post date:** [August 13, 2009, 10:34am UTC](https://www.ruby-forum.com/t/ann-geodesic-1-0-0-released/173687/1 "2009-08-13T10:34:17Z")

</div>

geodesic version 1.0.0 has been released!

- [http://github.com/kookjr/geodesic](http://github.com/kookjr/geodesic)

Geodesic is a Ruby library for calculating distance and bearing on the  
Earth’s surface using longitude and latitude. I found it helpful in  
some basic position management applications. See README at above site  
for install instructions.

Geodesic contains the following features:

- A Position class to encapsulate an Earth position  
(latitude and longitude)
- A method to calculate the distance between two positions  
using Haversine formula
- A method to calculate the distance between two positions  
using the Law of Cosines
- A method to calculate the initial bearing between two positions
- A method to calculate a position a given distance from another  
position along a bearing

Sample Usage  
require ‘rubygems’  
require ‘geodesic’

fremont = Geodesic::Position.new(37.549531, -121.998711)  
farmington = Geodesic::Position.new(37.923482, -121.015263)

d = Geodesic::dist\_haversine(fremont.lat, fremont.lon, farmington.lat,  
farmington.lon)  
print "distance from Fremont to Farmington is “, d, " kilometers\n”

b = Geodesic::bearing(fremont.lat, fremont.lon, farmington.lat,  
farmington.lon)  
print "bearing is “, b, " degrees\n”

p = Geodesic::dest\_position(fremont.lat, fremont.lon, b, d + 10)  
print "10 kilometers beyond farmington is ", p.lat, ", ", p.lon, “\n”

The output is:  
distance from Fremont to Farmington is 95.957632116596 kilometers  
bearing is 64.0206814526114 degrees  
10 kilometers beyond farmington is 37.9619800970259, -120.912203460738

Credits  
The original author of the JavaScript implementation, Chris Veness,  
can be found at:  
[Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript](http://www.movable-type.co.uk/scripts/latlong.html)

License  
GNU LGPL, Lesser General Public License version 2.1. For details,  
see file “COPYING.LESSER”.
