2
votes

For converting between Latitude/Longitude and UK's Ordnance Survey National Grid eastings and northings, this seems to be the most popular explanation and reference implementation in JavaScript: http://www.movable-type.co.uk/scripts/latlong-gridref.html

The web is littered with other implementations in different languages. Making the conversion via PostGIS queries is another alternative.

...but did anyone implement this maths in ruby?

LatLongToOSGrid is the direction I'm looking for just at this moment, but I would have thought a library for converting in both directions must surely be available in a gem somewhere. I'm just not searching for the right thing.

2
Here are some libraries in .Net, COM, Proj4... I don't know whether you can call them in Ruby stackoverflow.com/questions/1867950/…MarkJ
And the Ordnance Survey offer a free developer's pack with details of their "OSTN02/OSGM02" transformation and unit tests. Pretty heavy though. ordnancesurvey.co.uk/oswebsite/gps/osnetfreeservices/…MarkJ
Richard Fairhurst suggested Proj4 to me too, pointing out it has ruby bindings: proj4rb.rubyforge.org/proj4rb-doc/classes/Proj4.html Haven't tried that yet, but it looks like a good solution. Still surprised it hasn't been done in pure ruby though.Harry Wood

2 Answers

1
votes

I have now ported the javascript code to Ruby.

See my blog post "Ruby code for converting to UK Ordnance Survey coordinate systems from WGS84?"

And the linked code osgbconvert.rb

The blog post also details the proj4 ruby bindings approach and explains the coordinate systems involved.

1
votes

I've created a gem based on information derived from Harry's blog that I hope will be useful. The gem is call global_convert and the code can be found at https://github.com/reggieb/global_convert