NETGeographicLib::OSGB Class Reference

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

#include <NETGeographicLib/OSGB.h>

List of all members.

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 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 Forward (double lat, double lon,[System::Runtime::InteropServices::Out] double% x,[System::Runtime::InteropServices::Out] double% y)
static void Reverse (double x, double y,[System::Runtime::InteropServices::Out] double% lat,[System::Runtime::InteropServices::Out] double% lon)
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)
Inspector functions



static double MajorRadius ()
static double Flattening ()
static double CentralScale ()
static double OriginLatitude ()
static double OriginLongitude ()
static double FalseNorthing ()
static double FalseEasting ()

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;
using NETGeographicLib;

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:

using namespace System;
using namespace NETGeographicLib;

int main(array<System::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, x, y);
            String^ gridref;
            OSGB::GridReference(x, y, 2, 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, x, y, prec, true);
            double lat, lon;
            OSGB::Reverse(x, y, lat, lon);
            Console::WriteLine(String::Format("{0} {1} {2}", prec, lat, lon));
        }
    }
    catch (GeographicErr^ e) {
        Console::WriteLine(String::Format("Caught exception: {0}", e->Message));
        return 0;
    }
    return 0;
}

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.


Member Function Documentation

static void NETGeographicLib::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] 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).

static void NETGeographicLib::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] 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 NETGeographicLib::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.

static void NETGeographicLib::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.

static void NETGeographicLib::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] 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.

static void NETGeographicLib::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] 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).

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

static double NETGeographicLib::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.)

static double NETGeographicLib::OSGB::CentralScale (  )  [static]
Returns:
k0 central scale for the OSGB projection (0.9996012717).
static double NETGeographicLib::OSGB::OriginLatitude (  )  [static]
Returns:
latitude of the origin for the OSGB projection (49 degrees).
static double NETGeographicLib::OSGB::OriginLongitude (  )  [static]
Returns:
longitude of the origin for the OSGB projection (2 degrees).
static double NETGeographicLib::OSGB::FalseNorthing (  )  [static]
Returns:
false northing the OSGB projection (100000 meters).
static double NETGeographicLib::OSGB::FalseEasting (  )  [static]
Returns:
false easting the OSGB projection (400000 meters).

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

Generated on 6 Oct 2014 for NETGeographicLib by  doxygen 1.6.1