GeographicLib::OSGB Class Reference

Ordnance Survey grid system for Great Britain. More...

#include <GeographicLib/OSGB.hpp>

List of all members.

Static Public Member Functions

static void Forward (real lat, real lon, real &x, real &y, real &gamma, real &k)
static void Reverse (real x, real y, real &lat, real &lon, real &gamma, real &k)
static void Forward (real lat, real lon, real &x, real &y)
static void Reverse (real x, real y, real &lat, real &lon)
static void GridReference (real x, real y, int prec, std::string &gridref)
static void GridReference (const std::string &gridref, real &x, real &y, int &prec, bool centerp=true)
Inspector functions



static Math::real MajorRadius ()
static Math::real Flattening ()
static Math::real CentralScale ()
static Math::real OriginLatitude ()
static Math::real OriginLongitude ()
static Math::real FalseNorthing ()
static Math::real FalseEasting ()

Detailed Description

Ordnance Survey grid system for Great Britain.

The class implements the coordinate system used by the Ordnance Survey for maps of Great Britain and conversions to the grid reference system.

See

WARNING: the latitudes and longitudes for the Ordnance Survey grid system do not use the WGS84 datum. Do not use the values returned by this class in the UTMUPS, MGRS, or Geoid classes without first converting the datum (and vice versa).

Example of use:

// Example of using the GeographicLib::OSGB class

#include <iostream>
#include <iomanip>
#include <exception>
#include <string>
#include <GeographicLib/OSGB.hpp>
#include <GeographicLib/DMS.hpp>

using namespace std;
using namespace GeographicLib;

int main() {
  try {
    {
      // Sample forward calculation from
      // A guide to coordinate systems in Great Britain
      double
        lat = DMS::Decode(52,39,27.2531),
        lon = DMS::Decode( 1,43, 4.5177);
      double x, y;
      OSGB::Forward(lat, lon, x, y);
      string gridref;
      OSGB::GridReference(x, y, 2, gridref);
      cout << fixed << setprecision(3)
           << x << " " << y << " " << gridref << "\n";
    }
    {
      // Sample reverse calculation
      string gridref = "TG5113";
      double x, y;
      int prec;
      OSGB::GridReference(gridref, x, y, prec);
      double lat, lon;
      OSGB::Reverse(x, y, lat, lon);
      cout << fixed << setprecision(8)
           << prec << " " << lat << " " << lon << "\n";
    }
  }
  catch (const exception& e) {
    cerr << "Caught exception: " << e.what() << "\n";
    return 1;
  }
  return 0;
}

Definition at line 44 of file OSGB.hpp.


Member Function Documentation

static void GeographicLib::OSGB::Forward ( real  lat,
real  lon,
real &  x,
real &  y,
real &  gamma,
real &  k 
) [inline, static]

Forward projection, from geographic to OSGB coordinates.

Parameters:
[in] lat latitude of point (degrees).
[in] lon longitude of point (degrees).
[out] x easting of point (meters).
[out] y northing of point (meters).
[out] gamma meridian convergence at point (degrees).
[out] k scale of projection at point.

lat should be in the range [90, 90]; lon should be in the range [540, 540).

Definition at line 84 of file OSGB.hpp.

References GeographicLib::TransverseMercator::Forward().

static void GeographicLib::OSGB::Reverse ( real  x,
real  y,
real &  lat,
real &  lon,
real &  gamma,
real &  k 
) [inline, static]

Reverse projection, from OSGB coordinates to geographic.

Parameters:
[in] x easting of point (meters).
[in] y northing of point (meters).
[out] lat latitude of point (degrees).
[out] lon longitude of point (degrees).
[out] gamma meridian convergence at point (degrees).
[out] k scale of projection at point.

The value of lon returned is in the range [180, 180).

Definition at line 105 of file OSGB.hpp.

References GeographicLib::TransverseMercator::Reverse().

static void GeographicLib::OSGB::Forward ( real  lat,
real  lon,
real &  x,
real &  y 
) [inline, static]

OSGB::Forward without returning the convergence and scale.

Definition at line 115 of file OSGB.hpp.

static void GeographicLib::OSGB::Reverse ( real  x,
real  y,
real &  lat,
real &  lon 
) [inline, static]

OSGB::Reverse without returning the convergence and scale.

Definition at line 123 of file OSGB.hpp.

void GeographicLib::OSGB::GridReference ( real  x,
real  y,
int  prec,
std::string &  gridref 
) [static]

Convert OSGB coordinates to a grid reference.

Parameters:
[in] x easting of point (meters).
[in] y northing of point (meters).
[in] prec precision relative to 100 km.
[out] gridref National Grid reference.
Exceptions:
GeographicErr if prec, x, or y is outside its allowed range.
std::bad_alloc if the memory for gridref can't be allocatied.

prec specifies the precision of the grid reference string as follows:

  • prec = 0 (min), 100km
  • prec = 1, 10km
  • prec = 2, 1km
  • prec = 3, 100m
  • prec = 4, 10m
  • prec = 5, 1m
  • prec = 6, 0.1m
  • prec = 11 (max), 1m

The easting must be in the range [1000 km, 1500 km) and the northing must be in the range [500 km, 2000 km). These bounds are consistent with rules for the letter designations for the grid system.

Definition at line 39 of file OSGB.cpp.

References GeographicLib::Utility::str().

void GeographicLib::OSGB::GridReference ( const std::string &  gridref,
real &  x,
real &  y,
int &  prec,
bool  centerp = true 
) [static]

Convert OSGB coordinates to a grid reference.

Parameters:
[in] gridref National Grid reference.
[out] x easting of point (meters).
[out] y northing of point (meters).
[out] prec precision relative to 100 km.
[in] centerp if true (default), return center of the grid square, else return SW (lower left) corner.
Exceptions:
GeographicErr if gridref is illegal.

The grid reference must be of the form: two letters (not including I) followed by an even number of digits (up to 22).

Definition at line 87 of file OSGB.cpp.

References GeographicLib::Utility::lookup().

static Math::real GeographicLib::OSGB::MajorRadius (  )  [inline, static]
Returns:
a the equatorial radius of the Airy 1830 ellipsoid (meters).

This is 20923713 ft converted to meters using the rule 1 ft = 109.4840160310 m. (The Airy 1830 value is returned because the OSGB projection is based on this ellipsoid.)

Definition at line 185 of file OSGB.hpp.

static Math::real GeographicLib::OSGB::Flattening (  )  [inline, static]
Returns:
f the inverse flattening of the Airy 1830 ellipsoid.

For the Airy 1830 ellipsoid, a = 20923713 ft and b = 20853810 ft; thus the flattening = (20923713 20853810)/20923713 = 7767/2324857 = 1/299.32496459... (The Airy 1830 value is returned because the OSGB projection is based on this ellipsoid.)

Definition at line 200 of file OSGB.hpp.

static Math::real GeographicLib::OSGB::CentralScale (  )  [inline, static]
Returns:
k0 central scale for the OSGB projection (0.9996012717...).

C. J. Mugnier, Grids & Datums, PE&RS, Oct. 2003, states that this is defined as 109.999826810.

Definition at line 217 of file OSGB.hpp.

static Math::real GeographicLib::OSGB::OriginLatitude (  )  [inline, static]
Returns:
latitude of the origin for the OSGB projection (49 degrees).

Definition at line 225 of file OSGB.hpp.

static Math::real GeographicLib::OSGB::OriginLongitude (  )  [inline, static]
Returns:
longitude of the origin for the OSGB projection (2 degrees).

Definition at line 231 of file OSGB.hpp.

static Math::real GeographicLib::OSGB::FalseNorthing (  )  [inline, static]
Returns:
false northing the OSGB projection (100000 meters).

Definition at line 236 of file OSGB.hpp.

static Math::real GeographicLib::OSGB::FalseEasting (  )  [inline, static]
Returns:
false easting the OSGB projection (400000 meters).

Definition at line 241 of file OSGB.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 6 Oct 2014 for GeographicLib by  doxygen 1.6.1