Ordnance Survey Grid Reference functions.
$ npm install mt-osgridref
The module contains methods for parsing and converting between Ordnance Survey grid reference easting/northing coordinates and (OSGB36) latitude/longitude coordinates. It is also a basic representation of an easting/northing coordinate.
var OsGridRef = require('mt-osgridref');
var point = new OsGridRef(651409, 313177);
var latlon = OsGridRef.osGridToLatLong(point);
Creates a OsGridRef object.
- easting (number) Easting in metres from OS false origin
- northing (number) Northing in metres from OS false origin
var point = new OsGridRef(651409, 313177);
Convert (OSGB36) latitude/longitude to Ordnance Survey grid reference easting/northing coordinate.
- point (LatLon) OSGB36 latitude/longitude
var LatLon = require('mt-latlon');
var latlon = new LatLon(51.5136, -0.0983);
var point = OsGridRef.latLongToOsGrid(latlon);
Convert Ordnance Survey grid reference easting/northing coordinate to (OSGB36) latitude/longitude.
- gridref (OsGridRef) easting/northing to be converted to latitude/longitude
var gridref = OsGridRef.parse('SU387148');
var latlon = OsGridRef.osGridToLatLong(gridref);
Converts standard grid reference ('SU387148') to fully numeric reference ([438700,114800]). Returned coordinates are in metres, centred on supplied grid square.
- gridref (string) Standard format OS grid reference
var gridref = OsGridRef.parse('SU387148');
var latlon = OsGridRef.osGridToLatLong(gridref);
The original code was written by Chris Veness and can be found at http://www.movable-type.co.uk/scripts/latlong-gridref.html. It is released under the simple Creative Commons attribution license (http://creativecommons.org/licenses/by/3.0/).
This project is released under the MIT license.