OsNationalGrid is a Ruby gem that provides accurate transformations between the Ordnance Survey National Grid (OSGB36) and WGS84 (latitude/longitude) coordinate systems.
It uses the official mathematical transformations from the Ordnance Survey, including a Helmert transformation for precise conversions between coordinate systems.
Add to your Gemfile:
gem 'os_national_grid'
Then install:
bundle install
Or install it manually:
gem install os_national_grid
lng, lat = OsNationalGrid.os_ng_to_wgs84(481_987.066, 213_552.27)
=> [-0.812036, 51.814605]
easting, northing = OsNationalGrid.wgs84_to_os_ng(-0.812036, 51.814605)
=> [481987.066, 213552.27]
Run the test suite with:
bundle exec rake test
The gem is available as open source under the terms of the MIT License.