Class: OsGridRef

osgridref~OsGridRef

OS grid references with methods to parse and convert them to latitude/longitude points.

Constructor

new OsGridRef(easting, northing)

Creates an OsGridRef object.
Parameters:
Name Type Description
easting number Easting in metres from OS false origin.
northing number Northing in metres from OS false origin.
Source:

Methods

(static) parse(gridref) → {OsGridRef}

Parses grid reference to OsGridRef object. Accepts standard grid references (eg 'SU 387 148'), with or without whitespace separators, from two-digit references up to 10-digit references (1m × 1m square), or fully numeric comma-separated references in metres (eg '438700,114800').
Parameters:
Name Type Description
gridref string Standard format OS grid reference.
Source:
Throws:
Error on Invalid grid reference.
Returns:
Numeric version of grid reference in metres from false origin (SW corner of supplied grid square).
Type
OsGridRef
Example
var grid = OsGridRef.parse('TG 51409 13177'); // grid: { easting: 651409, northing: 313177 }

toLatLon(datumopt) → {LatLon}

Converts ‘this’ Ordnance Survey grid reference easting/northing coordinate to latitude/longitude (SW corner of grid square). Note formulation implemented here due to Thomas, Redfearn, etc is as published by OS, but is inferior to Krüger as used by e.g. Karney 2011.
Parameters:
Name Type Attributes Default Description
datum LatLon.datum <optional>
WGS84 Datum to convert grid reference into.
Source:
Returns:
Latitude/longitude of supplied grid reference.
Type
LatLon
Example
var gridref = new OsGridRef(651409.903, 313177.270);
  var pWgs84 = OsGridRef.osGridToLatLon(gridref);                     // 52°39′28.723″N, 001°42′57.787″E
  // to obtain (historical) OSGB36 latitude/longitude point:
  var pOsgb = OsGridRef.osGridToLatLon(gridref, LatLon.datum.OSGB36); // 52°39′27.253″N, 001°43′04.518″E

toString(digitsopt) → {string}

Converts ‘this’ numeric grid reference to standard OS grid reference.
Parameters:
Name Type Attributes Default Description
digits number <optional>
10 Precision of returned grid reference (10 digits = metres).
Source:
Returns:
This grid reference in standard format.
Type
string