OsNationalGrid
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.
Installation
Add to your Gemfile:
gem 'os_national_grid'Then install:
bundle installOr install it manually:
gem install os_national_gridUsage
Convert from OSGB36 (easting, northing) to WGS84 (longitude, latitude)
lng, lat = OsNationalGrid.os_ng_to_wgs84(481_987.066, 213_552.27)
=> [-0.812036, 51.814605]Convert from WGS84 (longitude, latitude) to OSGB36 (easting, northing)
easting, northing = OsNationalGrid.wgs84_to_os_ng(-0.812036, 51.814605)
=> [481987.066, 213552.27]Development
Run the test suite with:
bundle exec rake testLicense
The gem is available as open source under the terms of the MIT License.