|
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) |
|
|
static Math::real | EquatorialRadius () |
|
static Math::real | Flattening () |
|
static Math::real | CentralScale () |
|
static Math::real | OriginLatitude () |
|
static Math::real | OriginLongitude () |
|
static Math::real | FalseNorthing () |
|
static Math::real | FalseEasting () |
|
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:
#include <iostream>
#include <iomanip>
#include <exception>
#include <string>
try {
{
double
double x, y;
string gridref;
cout << fixed << setprecision(3)
<< x << " " << y << " " << gridref << "\n";
}
{
string gridref = "TG5113";
double x, y;
int prec;
double lat, lon;
cout << fixed << setprecision(8)
<< prec << " " << lat << " " << lon << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
int main(int argc, const char *const argv[])
Header for GeographicLib::DMS class.
Header for GeographicLib::OSGB class.
static Math::real Decode(const std::string &dms, flag &ind)
static void GridReference(real x, real y, int prec, std::string &gridref)
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)
Namespace for GeographicLib.
Definition at line 44 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), 1μm
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.
If x or y is NaN, the returned grid reference is "INVALID".
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 grid reference to coordinates.
- 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
-
The grid reference must be of the form: two letters (not including I) followed by an even number of digits (up to 22).
If the first 2 characters of gridref are "IN", then x and y are set to NaN and prec is set to −2.
Definition at line 93 of file OSGB.cpp.
References GeographicLib::Utility::lookup(), and GeographicLib::Math::NaN().