This gem allows you to gather U.K. Ordnance Survey Eastings, North, and Map References from a range of text inputs.
Add this line to your application's Gemfile:
gem 'os_map_ref'
And then execute:
$ bundle
Or install it yourself as:
$ gem install os_map_ref
To convert a map reference to eastings and northings:
location = OsMapRef::Location.for 'ST5880171043'
location.easting == 358801
location.northing == 171043
location.map_reference == 'ST 58801 71043'
To convert eastings and northings to a map reference:
location = OsMapRef::Location.for '358801, 171043'
location.easting == 358801
location.northing == 171043
location.map_reference == 'ST 58801 71043'
If your end result needs to be longitude and latitude, you can combine the OsMapRef output with that of another gem: global_convert
For example
require 'global_convert'
require 'os_map_ref'
os_location = OsMapRef::Location.for 'ST 58801 71043'
location = GlobalConvert::Location.new(
input: {
projection: :osgb36,
lon: os_location.easting,
lat: os_location.northing
},
output: {
projection: :wgs84
}
)
puts "Latitude = #{location.lat} in radians."
puts "Longitude = #{location.lon} in radians."
After checking out the repo, run bin/setup
to install dependencies.
Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Bug reports and pull requests are welcome on GitHub at https://github.com/reggieb/os_map_ref.