NETGeographicLib  1.40
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
OSGB.h
Go to the documentation of this file.
1 /**
2  * \file NETGeographicLib/OSGB.h
3  * \brief Header for NETGeographicLib::OSGB class
4  *
5  * NETGeographicLib is copyright (c) Scott Heiman (2013)
6  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
7  * <charles@karney.com> and licensed under the MIT/X11 License.
8  * For more information, see
9  * http://geographiclib.sourceforge.net/
10  **********************************************************************/
11 #pragma once
12 
13 namespace NETGeographicLib
14 {
15  /**
16  * \brief .NET wrapper for GeographicLib::OSGB.
17  *
18  * This class allows .NET applications to access GeographicLib::OSGB.
19  *
20  * The class implements the coordinate system used by the Ordnance Survey for
21  * maps of Great Britain and conversions to the grid reference system.
22  *
23  * See
24  * - <a href="http://www.ordnancesurvey.co.uk/docs/support/guide-coordinate-systems-great-britain.pdf">
25  * A guide to coordinate systems in Great Britain</a>
26  * - <a href="http://www.ordnancesurvey.co.uk/docs/support/national-grid.pdf">
27  * Guide to the National Grid</a>
28  *
29  * \b WARNING: the latitudes and longitudes for the Ordnance Survey grid
30  * system do not use the WGS84 datum. Do not use the values returned by this
31  * class in the UTMUPS, MGRS, or Geoid classes without first converting the
32  * datum (and vice versa).
33  *
34  * C# Example:
35  * \include example-OSGB.cs
36  * Managed C++ Example:
37  * \include example-OSGB.cpp
38  * Visual Basic Example:
39  * \include example-OSGB.vb
40  **********************************************************************/
41  public ref class OSGB
42  {
43  private:
44  // hide the constructor since all member are static
45  OSGB(void) {}
46  public:
47 
48  /**
49  * Forward projection, from geographic to OSGB coordinates.
50  *
51  * @param[in] lat latitude of point (degrees).
52  * @param[in] lon longitude of point (degrees).
53  * @param[out] x easting of point (meters).
54  * @param[out] y northing of point (meters).
55  * @param[out] gamma meridian convergence at point (degrees).
56  * @param[out] k scale of projection at point.
57  *
58  * \e lat should be in the range [&minus;90&deg;, 90&deg;]; \e lon
59  * should be in the range [&minus;540&deg;, 540&deg;).
60  **********************************************************************/
61  static void Forward(double lat, double lon,
62  [System::Runtime::InteropServices::Out] double% x,
63  [System::Runtime::InteropServices::Out] double% y,
64  [System::Runtime::InteropServices::Out] double% gamma,
65  [System::Runtime::InteropServices::Out] double% k);
66 
67  /**
68  * Reverse projection, from OSGB coordinates to geographic.
69  *
70  * @param[in] x easting of point (meters).
71  * @param[in] y northing of point (meters).
72  * @param[out] lat latitude of point (degrees).
73  * @param[out] lon longitude of point (degrees).
74  * @param[out] gamma meridian convergence at point (degrees).
75  * @param[out] k scale of projection at point.
76  *
77  * The value of \e lon returned is in the range [&minus;180&deg;,
78  * 180&deg;).
79  **********************************************************************/
80 
81  static void Reverse(double x, double y,
82  [System::Runtime::InteropServices::Out] double% lat,
83  [System::Runtime::InteropServices::Out] double% lon,
84  [System::Runtime::InteropServices::Out] double% gamma,
85  [System::Runtime::InteropServices::Out] double% k);
86 
87  /**
88  * OSGB::Forward without returning the convergence and scale.
89  **********************************************************************/
90  static void Forward(double lat, double lon,
91  [System::Runtime::InteropServices::Out] double% x,
92  [System::Runtime::InteropServices::Out] double% y);
93 
94  /**
95  * OSGB::Reverse without returning the convergence and scale.
96  **********************************************************************/
97  static void Reverse(double x, double y,
98  [System::Runtime::InteropServices::Out] double% lat,
99  [System::Runtime::InteropServices::Out] double% lon);
100 
101  /**
102  * Convert OSGB coordinates to a grid reference.
103  *
104  * @param[in] x easting of point (meters).
105  * @param[in] y northing of point (meters).
106  * @param[in] prec precision relative to 100 km.
107  * @param[out] gridref National Grid reference.
108  * @exception GeographicErr if \e prec, \e x, or \e y is outside its
109  * allowed range.
110  * @exception std::bad_alloc if the memory for \e gridref can't be
111  * allocatied.
112  *
113  * \e prec specifies the precision of the grid reference string as follows:
114  * - prec = 0 (min), 100km
115  * - prec = 1, 10km
116  * - prec = 2, 1km
117  * - prec = 3, 100m
118  * - prec = 4, 10m
119  * - prec = 5, 1m
120  * - prec = 6, 0.1m
121  * - prec = 11 (max), 1&mu;m
122  *
123  * The easting must be in the range [&minus;1000 km, 1500 km) and the
124  * northing must be in the range [&minus;500 km, 2000 km). These bounds
125  * are consistent with rules for the letter designations for the grid
126  * system.
127  *
128  * If \e x or \e y is NaN, the returned grid reference is "INVALID".
129  **********************************************************************/
130  static void GridReference(double x, double y, int prec,
131  [System::Runtime::InteropServices::Out] System::String^% gridref);
132 
133  /**
134  * Convert OSGB coordinates to a grid reference.
135  *
136  * @param[in] gridref National Grid reference.
137  * @param[out] x easting of point (meters).
138  * @param[out] y northing of point (meters).
139  * @param[out] prec precision relative to 100 km.
140  * @param[in] centerp if true (default), return center of the grid square,
141  * else return SW (lower left) corner.
142  * @exception GeographicErr if \e gridref is illegal.
143  *
144  * The grid reference must be of the form: two letters (not including I)
145  * followed by an even number of digits (up to 22).
146  *
147  * If the first 2 characters of \e gridref are "IN", then \e x and \e y are
148  * set to NaN and \e prec is set to &minus;2.
149  **********************************************************************/
150  static void GridReference(System::String^ gridref,
151  [System::Runtime::InteropServices::Out] double% x,
152  [System::Runtime::InteropServices::Out] double% y,
153  [System::Runtime::InteropServices::Out] int% prec,
154  bool centerp );
155 
156  /** \name Inspector functions
157  **********************************************************************/
158  ///@{
159  /**
160  * @return \e a the equatorial radius of the Airy 1830 ellipsoid (meters).
161  *
162  * This is 20923713 ft converted to meters using the rule 1 ft =
163  * 10<sup>9.48401603&minus;10</sup> m. (The Airy 1830 value is returned
164  * because the OSGB projection is based on this ellipsoid.)
165  **********************************************************************/
166  static double MajorRadius();
167 
168  /**
169  * @return \e f the inverse flattening of the Airy 1830 ellipsoid.
170  *
171  * For the Airy 1830 ellipsoid, \e a = 20923713 ft and \e b = 20853810 ft;
172  * thus the flattening = (20923713 &minus; 20853810)/20923713 =
173  * 7767/2324857 = 1/299.32496459... (The Airy 1830 value is returned
174  * because the OSGB projection is based on this ellipsoid.)
175  **********************************************************************/
176  static double Flattening();
177 
178  /**
179  * @return \e k0 central scale for the OSGB projection (0.9996012717).
180  **********************************************************************/
181  static double CentralScale();
182 
183  /**
184  * @return latitude of the origin for the OSGB projection (49 degrees).
185  **********************************************************************/
186  static double OriginLatitude();
187 
188  /**
189  * @return longitude of the origin for the OSGB projection (&minus;2
190  * degrees).
191  **********************************************************************/
192  static double OriginLongitude();
193 
194  /**
195  * @return false northing the OSGB projection (&minus;100000 meters).
196  **********************************************************************/
197  static double FalseNorthing();
198 
199  /**
200  * @return false easting the OSGB projection (400000 meters).
201  **********************************************************************/
202  static double FalseEasting();
203  ///@}
204  };
205 } //
static double FalseNorthing()
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 GridReference(double x, double y, int prec, [System::Runtime::InteropServices::Out] System::String^ %gridref)
static double Flattening()
static double FalseEasting()
static double OriginLatitude()
static double OriginLongitude()
static double CentralScale()
.NET wrapper for GeographicLib::OSGB.
Definition: OSGB.h:41
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 double MajorRadius()