Skip to content

peterhaldbaek/mt-osgridref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mt-osgridref

Ordnance Survey Grid Reference functions.

Installation

$ npm install mt-osgridref

Usage

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);

OsGridRef(easting, northing)

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);

OsGridRef.latLongToOsGrid(point)

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);

OsGridRef.osGridToLatLong(gridref)

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);

OsGridRef.parse(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);

Copyright and license

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.

About

Ordnance Survey Grid Reference functions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published