Static Public Member Functions | Private Member Functions | List of all members
NETGeographicLib::OSGB Class Reference

.NET wrapper for GeographicLib::OSGB. More...

#include <OSGB.h>

Static Public Member Functions

static void Forward (double lat, double lon, [System::Runtime::InteropServices::Out] double%x, [System::Runtime::InteropServices::Out] double%y, [System::Runtime::InteropServices::Out] double%gamma, [System::Runtime::InteropServices::Out] double%k)
 
static void Forward (double lat, double lon, [System::Runtime::InteropServices::Out] double%x, [System::Runtime::InteropServices::Out] double%y)
 
static void GridReference (double x, double y, int prec, [System::Runtime::InteropServices::Out] System::String^%gridref)
 
static void GridReference (System::String^gridref, [System::Runtime::InteropServices::Out] double%x, [System::Runtime::InteropServices::Out] double%y, [System::Runtime::InteropServices::Out] int%prec, bool centerp)
 
static void Reverse (double x, double y, [System::Runtime::InteropServices::Out] double%lat, [System::Runtime::InteropServices::Out] double%lon, [System::Runtime::InteropServices::Out] double%gamma, [System::Runtime::InteropServices::Out] double%k)
 
static void Reverse (double x, double y, [System::Runtime::InteropServices::Out] double%lat, [System::Runtime::InteropServices::Out] double%lon)
 
Inspector functions
static double MajorRadius ()
 
static double Flattening ()
 
static double CentralScale ()
 
static double OriginLatitude ()
 
static double OriginLongitude ()
 
static double FalseNorthing ()
 
static double FalseEasting ()
 

Private Member Functions

 OSGB (void)
 

Detailed Description

.NET wrapper for GeographicLib::OSGB.

This class allows .NET applications to access GeographicLib::OSGB.

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).

C# Example:

using System;
namespace example_OSGB
{
class Program
{
static void Main(string[] args)
{
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, out x, out y);
string gridref;
OSGB.GridReference(x, y, 2, out gridref);
Console.WriteLine(String.Format("{0} {1} {2}", x, y, gridref));
}
{
// Sample reverse calculation
string gridref = "TG5113";
double x, y;
int prec;
OSGB.GridReference(gridref, out x, out y, out prec, true);
double lat, lon;
OSGB.Reverse(x, y, out lat, out lon);
Console.WriteLine(String.Format("{0} {1} {2}", prec, lat, lon));
}
}
catch (GeographicErr e) {
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}

Managed C++ Example:

// 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;
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;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_OSGB
Sub Main()
Try
' Sample forward calculation from
' A guide to coordinate systems in Great Britain
Dim lat As Double = DMS.Decode(52, 39, 27.2531)
Dim lon As Double = DMS.Decode(1, 43, 4.5177)
Dim x, y As Double
OSGB.Forward(lat, lon, x, y)
Dim gridref As String = ""
OSGB.GridReference(x, y, 2, gridref)
Console.WriteLine(String.Format("{0} {1} {2}", x, y, gridref))
' Sample reverse calculation
gridref = "TG5113"
Dim prec As Integer
OSGB.GridReference(gridref, x, y, prec, True)
OSGB.Reverse(x, y, lat, lon)
Console.WriteLine(String.Format("{0} {1} {2}", prec, lat, lon))
Catch ex As GeographicErr
Console.WriteLine(String.Format("Caught exception: {0}", ex.Message))
End Try
End Sub
End Module

Definition at line 41 of file OSGB.h.

Constructor & Destructor Documentation

NETGeographicLib::OSGB::OSGB ( void  )
inlineprivate

Definition at line 45 of file OSGB.h.

Member Function Documentation

double OSGB::CentralScale ( )
static
Returns
k0 central scale for the OSGB projection (0.9996012717).

Definition at line 121 of file dotnet/NETGeographicLib/OSGB.cpp.

double OSGB::FalseEasting ( )
static
Returns
false easting the OSGB projection (400000 meters).

Definition at line 134 of file dotnet/NETGeographicLib/OSGB.cpp.

double OSGB::FalseNorthing ( )
static
Returns
false northing the OSGB projection (−100000 meters).

Definition at line 131 of file dotnet/NETGeographicLib/OSGB.cpp.

double OSGB::Flattening ( )
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 118 of file dotnet/NETGeographicLib/OSGB.cpp.

void OSGB::Forward ( double  lat,
double  lon,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y,
[System::Runtime::InteropServices::Out] double%  gamma,
[System::Runtime::InteropServices::Out] double%  k 
)
static

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 19 of file dotnet/NETGeographicLib/OSGB.cpp.

void OSGB::Forward ( double  lat,
double  lon,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y 
)
static

OSGB::Forward without returning the convergence and scale.

Definition at line 49 of file dotnet/NETGeographicLib/OSGB.cpp.

void OSGB::GridReference ( double  x,
double  y,
int  prec,
[System::Runtime::InteropServices::Out] System::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 71 of file dotnet/NETGeographicLib/OSGB.cpp.

void OSGB::GridReference ( System::String^  gridref,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y,
[System::Runtime::InteropServices::Out] int prec,
bool  centerp 
)
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 91 of file dotnet/NETGeographicLib/OSGB.cpp.

double OSGB::MajorRadius ( )
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.48401603−10 m. (The Airy 1830 value is returned because the OSGB projection is based on this ellipsoid.)

Definition at line 115 of file dotnet/NETGeographicLib/OSGB.cpp.

double OSGB::OriginLatitude ( )
static
Returns
latitude of the origin for the OSGB projection (49 degrees).

Definition at line 124 of file dotnet/NETGeographicLib/OSGB.cpp.

double OSGB::OriginLongitude ( )
static
Returns
longitude of the origin for the OSGB projection (−2 degrees).

Definition at line 127 of file dotnet/NETGeographicLib/OSGB.cpp.

void OSGB::Reverse ( double  x,
double  y,
[System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon,
[System::Runtime::InteropServices::Out] double%  gamma,
[System::Runtime::InteropServices::Out] double%  k 
)
static

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 34 of file dotnet/NETGeographicLib/OSGB.cpp.

void OSGB::Reverse ( double  x,
double  y,
[System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon 
)
static

OSGB::Reverse without returning the convergence and scale.

Definition at line 60 of file dotnet/NETGeographicLib/OSGB.cpp.


The documentation for this class was generated from the following files:


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:59:11