Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
GeographicLib::OSGB Class Reference

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

#include <OSGB.hpp>

Static Public Member Functions

static void Forward (real lat, real lon, real &x, real &y)
 
static void Forward (real lat, real lon, real &x, real &y, real &gamma, real &k)
 
static void GridReference (const std::string &gridref, real &x, real &y, int &prec, bool centerp=true)
 
static void GridReference (real x, real y, int prec, std::string &gridref)
 
static void Reverse (real x, real y, real &lat, real &lon)
 
static void Reverse (real x, real y, real &lat, real &lon, real &gamma, real &k)
 
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 ()
 

Private Types

enum  {
  base_ = 10, tile_ = 100000, tilelevel_ = 5, tilegrid_ = 5,
  tileoffx_ = 2 * tilegrid_, tileoffy_ = 1 * tilegrid_, minx_ = - tileoffx_ * tile_, miny_ = - tileoffy_ * tile_,
  maxx_ = (tilegrid_*tilegrid_ - tileoffx_) * tile_, maxy_ = (tilegrid_*tilegrid_ - tileoffy_) * tile_, maxprec_ = 5 + 6
}
 
typedef Math::real real
 

Private Member Functions

 OSGB ()
 

Static Private Member Functions

static void CheckCoords (real x, real y)
 
static real computenorthoffset ()
 
static const TransverseMercatorOSGBTM ()
 

Static Private Attributes

static const char *const digits_ = "0123456789"
 
static const char *const letters_ = "ABCDEFGHJKLMNOPQRSTUVWXYZ"
 

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>
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;
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;
cout << fixed << setprecision(8)
<< prec << " " << lat << " " << lon << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

Definition at line 44 of file OSGB.hpp.

Member Typedef Documentation

◆ real

Definition at line 46 of file OSGB.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
base_ 
tile_ 
tilelevel_ 
tilegrid_ 
tileoffx_ 
tileoffy_ 
minx_ 
miny_ 
maxx_ 
maxy_ 
maxprec_ 

Definition at line 50 of file OSGB.hpp.

Constructor & Destructor Documentation

◆ OSGB()

GeographicLib::OSGB::OSGB ( )
private

Member Function Documentation

◆ CentralScale()

static Math::real GeographicLib::OSGB::CentralScale ( )
inlinestatic
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.9998268−10.

Definition at line 214 of file OSGB.hpp.

◆ CheckCoords()

void GeographicLib::OSGB::CheckCoords ( real  x,
real  y 
)
staticprivate

Definition at line 152 of file src/OSGB.cpp.

◆ computenorthoffset()

Math::real GeographicLib::OSGB::computenorthoffset ( )
staticprivate

Definition at line 26 of file src/OSGB.cpp.

◆ FalseEasting()

static Math::real GeographicLib::OSGB::FalseEasting ( )
inlinestatic
Returns
false easting the OSGB projection (400000 meters).

Definition at line 238 of file OSGB.hpp.

◆ FalseNorthing()

static Math::real GeographicLib::OSGB::FalseNorthing ( )
inlinestatic
Returns
false northing the OSGB projection (−100000 meters).

Definition at line 233 of file OSGB.hpp.

◆ Flattening()

static Math::real GeographicLib::OSGB::Flattening ( )
inlinestatic
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 205 of file OSGB.hpp.

◆ Forward() [1/2]

static void GeographicLib::OSGB::Forward ( real  lat,
real  lon,
real x,
real y 
)
inlinestatic

OSGB::Forward without returning the convergence and scale.

Definition at line 112 of file OSGB.hpp.

◆ Forward() [2/2]

static void GeographicLib::OSGB::Forward ( real  lat,
real  lon,
real x,
real y,
real gamma,
real k 
)
inlinestatic

Forward projection, from geographic to OSGB coordinates.

Parameters
[in]latlatitude of point (degrees).
[in]lonlongitude of point (degrees).
[out]xeasting of point (meters).
[out]ynorthing of point (meters).
[out]gammameridian convergence at point (degrees).
[out]kscale of projection at point.

lat should be in the range [−90°, 90°].

Definition at line 81 of file OSGB.hpp.

◆ GridReference() [1/2]

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]gridrefNational Grid reference.
[out]xeasting of point (meters).
[out]ynorthing of point (meters).
[out]precprecision relative to 100 km.
[in]centerpif true (default), return center of the grid square, else return SW (lower left) corner.
Exceptions
GeographicErrif 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).

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 87 of file src/OSGB.cpp.

◆ GridReference() [2/2]

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

Convert OSGB coordinates to a grid reference.

Parameters
[in]xeasting of point (meters).
[in]ynorthing of point (meters).
[in]precprecision relative to 100 km.
[out]gridrefNational Grid reference.
Exceptions
GeographicErrif prec, x, or y is outside its allowed range.
std::bad_allocif 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 34 of file src/OSGB.cpp.

◆ MajorRadius()

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

This is 20923713 ft converted to meters using the rule 1 ft = 109.48401603−10 m. The Airy 1830 value is returned because the OSGB projection is based on this ellipsoid. The conversion factor from feet to meters is the one used for the 1936 retriangulation of Britain; see Section A.1 (p. 37) of A guide to coordinate systems in Great Britain, v2.2 (Dec. 2013).

Definition at line 190 of file OSGB.hpp.

◆ OriginLatitude()

static Math::real GeographicLib::OSGB::OriginLatitude ( )
inlinestatic
Returns
latitude of the origin for the OSGB projection (49 degrees).

Definition at line 222 of file OSGB.hpp.

◆ OriginLongitude()

static Math::real GeographicLib::OSGB::OriginLongitude ( )
inlinestatic
Returns
longitude of the origin for the OSGB projection (−2 degrees).

Definition at line 228 of file OSGB.hpp.

◆ OSGBTM()

const TransverseMercator & GeographicLib::OSGB::OSGBTM ( )
staticprivate

Definition at line 20 of file src/OSGB.cpp.

◆ Reverse() [1/2]

static void GeographicLib::OSGB::Reverse ( real  x,
real  y,
real lat,
real lon 
)
inlinestatic

OSGB::Reverse without returning the convergence and scale.

Definition at line 120 of file OSGB.hpp.

◆ Reverse() [2/2]

static void GeographicLib::OSGB::Reverse ( real  x,
real  y,
real lat,
real lon,
real gamma,
real k 
)
inlinestatic

Reverse projection, from OSGB coordinates to geographic.

Parameters
[in]xeasting of point (meters).
[in]ynorthing of point (meters).
[out]latlatitude of point (degrees).
[out]lonlongitude of point (degrees).
[out]gammameridian convergence at point (degrees).
[out]kscale of projection at point.

The value of lon returned is in the range [−180°, 180°].

Definition at line 102 of file OSGB.hpp.

Member Data Documentation

◆ digits_

const char *const GeographicLib::OSGB::digits_ = "0123456789"
staticprivate

Definition at line 48 of file OSGB.hpp.

◆ letters_

const char *const GeographicLib::OSGB::letters_ = "ABCDEFGHJKLMNOPQRSTUVWXYZ"
staticprivate

Definition at line 47 of file OSGB.hpp.


The documentation for this class was generated from the following files:
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
GeographicLib::OSGB::Forward
static void Forward(real lat, real lon, real &x, real &y, real &gamma, real &k)
Definition: OSGB.hpp:81
GeographicLib::DMS::Decode
static Math::real Decode(const std::string &dms, flag &ind)
Definition: src/DMS.cpp:28
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
GeographicLib::OSGB::GridReference
static void GridReference(real x, real y, int prec, std::string &gridref)
Definition: src/OSGB.cpp:34
OSGB.hpp
Header for GeographicLib::OSGB class.
GeographicLib::OSGB::Reverse
static void Reverse(real x, real y, real &lat, real &lon, real &gamma, real &k)
Definition: OSGB.hpp:102
y
Scalar * y
Definition: level1_cplx_impl.h:124
std
Definition: BFloat16.h:88
lon
static const double lon
Definition: testGeographicLib.cpp:34
DMS.hpp
Header for GeographicLib::DMS class.
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:15:07