Class: DefraRuby::Address::EastingNorthingToLatLonService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/defra_ruby/address/services/easting_northing_to_lat_lon_service.rb

Overview

Converts a British National Grid easting and northing to a WGS84 latitude and longitude. Accurate to around 5 metres.

Instance Method Summary collapse

Methods inherited from BaseService

run

Instance Method Details

#run(easting, northing) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/defra_ruby/address/services/easting_northing_to_lat_lon_service.rb', line 8

def run(easting, northing)
  osgb36_latitude, osgb36_longitude = TransverseMercatorProjection.easting_northing_to_lat_lon(
    Float(easting), Float(northing)
  )
  latitude, longitude = HelmertTransformation.osgb36_to_wgs84(osgb36_latitude, osgb36_longitude)

  { latitude: latitude, longitude: longitude }
end