GeographicLib
1.21
|
Ordnance Survey grid system for Great Britain. More...
#include <GeographicLib/OSGB.hpp>
Static Public Member Functions | |
static void | Forward (real lat, real lon, real &x, real &y, real &gamma, real &k) throw () |
static void | Reverse (real x, real y, real &lat, real &lon, real &gamma, real &k) throw () |
static void | Forward (real lat, real lon, real &x, real &y) throw () |
static void | Reverse (real x, real y, real &lat, real &lon) throw () |
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 () throw () |
static Math::real | Flattening () throw () |
static Math::real | CentralScale () throw () |
static Math::real | OriginLatitude () throw () |
static Math::real | OriginLongitude () throw () |
static Math::real | FalseNorthing () throw () |
static Math::real | FalseEasting () throw () |
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 // $Id: 80feea12c2ebb7e594d8e17bf841c1a141cf3c36 $ #include <iostream> #include <exception> #include <string> #include <GeographicLib/OSGB.hpp> using namespace std; using namespace GeographicLib; int main() { try { { // Sample forward calculation double lat = 55.5, lon = -1.64; // Embleton, Northumberland double x, y; OSGB::Forward(lat, lon, x, y); string gridref; OSGB::GridReference(x, y, 2, gridref); cout << x << " " << y << " " << gridref << "\n"; } { // Sample reverse calculation string gridref = "NU2222"; double x, y; int prec; OSGB::GridReference(gridref, x, y, prec); double lat, lon; OSGB::Reverse(x, y, lat, lon); cout << prec << " " << lat << " " << lon << "\n"; } } catch (const exception& e) { cerr << "Caught exception: " << e.what() << "\n"; return 1; } return 0; }
static void GeographicLib::OSGB::Forward | ( | real | lat, |
real | lon, | ||
real & | x, | ||
real & | y, | ||
real & | gamma, | ||
real & | k | ||
) | throw () [inline, static] |
Forward projection, from geographic to OSGB coordinates.
[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 and lon0 should be in the range [-180, 360].
static void GeographicLib::OSGB::Reverse | ( | real | x, |
real | y, | ||
real & | lat, | ||
real & | lon, | ||
real & | gamma, | ||
real & | k | ||
) | throw () [inline, static] |
Reverse projection, from OSGB coordinates to geographic.
[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).
static void GeographicLib::OSGB::Forward | ( | real | lat, |
real | lon, | ||
real & | x, | ||
real & | y | ||
) | throw () [inline, static] |
OSGB::Forward without returning the convergence and scale.
static void GeographicLib::OSGB::Reverse | ( | real | x, |
real | y, | ||
real & | lat, | ||
real & | lon | ||
) | throw () [inline, static] |
OSGB::Reverse without returning the convergence and scale.
void GeographicLib::OSGB::GridReference | ( | real | x, |
real | y, | ||
int | prec, | ||
std::string & | gridref | ||
) | [static] |
Convert OSGB coordinates to a grid reference.
[in] | x | easting of point (meters). |
[in] | y | northing of point (meters). |
[in] | prec | precision relative to 100 km. |
[out] | gridref | National Grid reference. |
prec specifies the precision of the grid reference string as follows:
The easting must be in the range [-1000 km, 1500 km) and the northing must be in the range [-500 km, 2000 km). An exception is thrown if either the easting and northing is outside these bounds. These bounds are consistent with rules for the letter designations for the grid system.
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.
[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. |
The grid reference must be of the form: two letters (not including I) followed by an even number of digits (up to 22).
static Math::real GeographicLib::OSGB::MajorRadius | ( | ) | throw () [inline, static] |
static Math::real GeographicLib::OSGB::Flattening | ( | ) | throw () [inline, static] |
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.)
static Math::real GeographicLib::OSGB::CentralScale | ( | ) | throw () [inline, static] |
static Math::real GeographicLib::OSGB::OriginLatitude | ( | ) | throw () [inline, static] |
static Math::real GeographicLib::OSGB::OriginLongitude | ( | ) | throw () [inline, static] |
static Math::real GeographicLib::OSGB::FalseNorthing | ( | ) | throw () [inline, static] |
static Math::real GeographicLib::OSGB::FalseEasting | ( | ) | throw () [inline, static] |