NETGeographicLib  1.38
 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  static void GridReference(double x, double y, int prec,
129  [System::Runtime::InteropServices::Out] System::String^% gridref);
130 
131  /**
132  * Convert OSGB coordinates to a grid reference.
133  *
134  * @param[in] gridref National Grid reference.
135  * @param[out] x easting of point (meters).
136  * @param[out] y northing of point (meters).
137  * @param[out] prec precision relative to 100 km.
138  * @param[in] centerp if true (default), return center of the grid square,
139  * else return SW (lower left) corner.
140  * @exception GeographicErr if \e gridref is illegal.
141  *
142  * The grid reference must be of the form: two letters (not including I)
143  * followed by an even number of digits (up to 22).
144  **********************************************************************/
145  static void GridReference(System::String^ gridref,
146  [System::Runtime::InteropServices::Out] double% x,
147  [System::Runtime::InteropServices::Out] double% y,
148  [System::Runtime::InteropServices::Out] int% prec,
149  bool centerp );
150 
151  /** \name Inspector functions
152  **********************************************************************/
153  ///@{
154  /**
155  * @return \e a the equatorial radius of the Airy 1830 ellipsoid (meters).
156  *
157  * This is 20923713 ft converted to meters using the rule 1 ft =
158  * 10<sup>9.48401603&minus;10</sup> m. (The Airy 1830 value is returned
159  * because the OSGB projection is based on this ellipsoid.)
160  **********************************************************************/
161  static double MajorRadius();
162 
163  /**
164  * @return \e f the inverse flattening of the Airy 1830 ellipsoid.
165  *
166  * For the Airy 1830 ellipsoid, \e a = 20923713 ft and \e b = 20853810 ft;
167  * thus the flattening = (20923713 &minus; 20853810)/20923713 =
168  * 7767/2324857 = 1/299.32496459... (The Airy 1830 value is returned
169  * because the OSGB projection is based on this ellipsoid.)
170  **********************************************************************/
171  static double Flattening();
172 
173  /**
174  * @return \e k0 central scale for the OSGB projection (0.9996012717).
175  **********************************************************************/
176  static double CentralScale();
177 
178  /**
179  * @return latitude of the origin for the OSGB projection (49 degrees).
180  **********************************************************************/
181  static double OriginLatitude();
182 
183  /**
184  * @return longitude of the origin for the OSGB projection (&minus;2
185  * degrees).
186  **********************************************************************/
187  static double OriginLongitude();
188 
189  /**
190  * @return false northing the OSGB projection (&minus;100000 meters).
191  **********************************************************************/
192  static double FalseNorthing();
193 
194  /**
195  * @return false easting the OSGB projection (400000 meters).
196  **********************************************************************/
197  static double FalseEasting();
198  ///@}
199  };
200 } //