Skip to content

JS package to parse Ordnance Survey Great Britain alpha-numeric grid references into a bounding box. Distributed as an ES module.

License

Notifications You must be signed in to change notification settings

AstunTechnology/gridref-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gridref-js

Parse Ordnance Survey Great Britain alpha numeric grid references into a bounding box.

Installation

npm i @astuntech/gridref-js

Usage

import { parse, InvalidGridRef } from './gridref-js';

try {
  var bbox = parse('SU387148');
  console.log(bbox);
} catch (e) {
  if (e instanceof InvalidGridRef) {
    console.error(e.message);
  } else {
    throw e;
  }
}

API

parse(gridref) ⇒ Array.<Number>

Converts OSGB grid reference ('SU387148') to bounding box in British National Grid ([438700, 114800, 438800, 114900])

Kind: global function
Returns: Array.<Number> - Bounding box of grid reference in metres

Param Type Description
gridref String Standard format OSGB grid reference (e.g. SU387148)

Credit

Derived from https://github.com/peterhaldbaek/mt-osgridref

License

MIT

About

JS package to parse Ordnance Survey Great Britain alpha-numeric grid references into a bounding box. Distributed as an ES module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published