jadpo

packages / @jadpo

@jadpo/british-grid

Grid references to latitude and longitude: British National Grid eastings and northings to OSGB36, ETRS89 and WGS84, and Irish Grid ones to ETRS89 and WGS84, by ospoint's method (MIT, Ideal Postcodes): good to a few metres, not survey grade.

Install
jadpo package add @jadpo/british-grid

Adds the newest version, skipping any that were withdrawn (yanked) and pre-releases such as 2.0.0-beta.1. --to 1.0.0 picks a version. Your app then calls it as BritishGrid.v1.

Use it in your app

@jadpo hasn't added a recipe to this package yet. A recipe is a working example of using the package in an app. After installing it, jadpo package show @jadpo/british-grid lists its operations (the calls it makes to an outside API), functions and types, and the guide on installing and using a package shows how to add one to your app.

What this package can do

  • Works only on the values your app gives itIt doesn't call any other service or store anything, so it can't change your database or send data anywhere.
  • Can fail in ways your app must handle3 functions can fail: convert.to_etrs89 can fail with OutsideGrid and UnsupportedGrid; convert.to_osgb36 can fail with OutsideGrid and UnsupportedGrid; convert.to_wgs84 can fail with OutsideGrid and UnsupportedGrid. Your app must say what happens when each does, and it won't compile until it does.
  • Works with Jadpo 0.6.0, Jadpo's newest releaseIt works with 0.4.0, 0.4.1 and 0.5.0 too. Each time a new Jadpo release comes out, jadpo.dev checks every package's newest version with it.0.4.0 · 0.4.1 · 0.5.0 · 0.6.0

jadpo.dev works out what this package can do from its code each time it checks a version, such as which services it calls and what personal data it sends, so the list doesn't depend on what its author says.

Guidewritten by @jadpo

Call convert.to_wgs84 with an EastingNorthing to get a Point you can store, measure with geo.distance and send as GeoJSON. Its crs says which grid: EPSG:27700 for the British National Grid, EPSG:29902 for the Irish Grid. Ordnance Survey's Code-Point Open and most UK address data give the British one, sometimes with leading zeros on the northing, which a number drops harmlessly.

Use convert.to_osgb36 only where something else works in OSGB36 degrees, such as old Ordnance Survey maps; it never mixes with a Point.

Both failures are about the input, never the method: UnsupportedGrid when the Crs is one this package doesn't convert, OutsideGrid when an easting or northing is off its grid. Report either as a bad reference.

Results are good to a few metres, not survey grade. For survey work, convert with Ordnance Survey's OSTN15 instead.

What it offersgenerated from the package's code

Functions

Functions your app can call.

convert.to_etrs89

A British National Grid or Irish Grid position as latitude and longitude on ETRS89, through ospoint's Helmert transformation: typically within a few metres, not survey grade.

signature (position: EastingNorthing) -> Etrs89Position
fails OutsideGrid
fails UnsupportedGrid
convert.to_osgb36

A British National Grid position as latitude and longitude on OSGB36, the grid's own datum: Ordnance Survey's projection equations alone, with no change of datum, so good to well under a millimetre.

signature (position: EastingNorthing) -> Osgb36Position
fails OutsideGrid
fails UnsupportedGrid
convert.to_wgs84

A British National Grid or Irish Grid position as a WGS84 `Point`. As ospoint does, it gives the ETRS89 coordinates: the two datums drift apart by about 2.5 cm a year, which is below this method's accuracy.

signature (position: EastingNorthing) -> Point
fails OutsideGrid
fails UnsupportedGrid

Types

The shapes of the values it takes and gives back.

Etrs89Position= Object

A latitude and a longitude in decimal degrees on ETRS89, the datum fixed to Europe that GPS positions in Britain are surveyed in. It drifts from WGS84 by about 2.5 cm a year, which is why it is kept apart from `Point`.

latitude: Latitude
longitude: Longitude
Osgb36Position= Object

A latitude and a longitude in decimal degrees on OSGB36, the datum of the British National Grid, on the Airy 1830 ellipsoid. OSGB36 lies around 100 metres from WGS84, so this is never a `Point`.

latitude: Latitude
longitude: Longitude

Failures

The errors its calls can end with, which your app must handle.

OutsideGrid

The easting or the northing is outside its grid: below 0, or past 700,000 east or 1,300,000 north on the British National Grid and 400,000 east or 500,000 north on the Irish Grid.

kind invalid_value
UnsupportedGrid

The position's `Crs` isn't a grid the conversion knows: the British National Grid, `EPSG:27700`, or for ETRS89 and WGS84 also the Irish Grid, `EPSG:29902`.

kind invalid_value