NETGeographicLib  1.51
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  * https://geographiclib.sourceforge.io/
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;].
59  **********************************************************************/
60  static void Forward(double lat, double lon,
61  [System::Runtime::InteropServices::Out] double% x,
62  [System::Runtime::InteropServices::Out] double% y,
63  [System::Runtime::InteropServices::Out] double% gamma,
64  [System::Runtime::InteropServices::Out] double% k);
65 
66  /**
67  * Reverse projection, from OSGB coordinates to geographic.
68  *
69  * @param[in] x easting of point (meters).
70  * @param[in] y northing of point (meters).
71  * @param[out] lat latitude of point (degrees).
72  * @param[out] lon longitude of point (degrees).
73  * @param[out] gamma meridian convergence at point (degrees).
74  * @param[out] k scale of projection at point.
75  *
76  * The value of \e lon returned is in the range [&minus;180&deg;,
77  * 180&deg;).
78  **********************************************************************/
79 
80  static void Reverse(double x, double y,
81  [System::Runtime::InteropServices::Out] double% lat,
82  [System::Runtime::InteropServices::Out] double% lon,
83  [System::Runtime::InteropServices::Out] double% gamma,
84  [System::Runtime::InteropServices::Out] double% k);
85 
86  /**
87  * OSGB::Forward without returning the convergence and scale.
88  **********************************************************************/
89  static void Forward(double lat, double lon,
90  [System::Runtime::InteropServices::Out] double% x,
91  [System::Runtime::InteropServices::Out] double% y);
92 
93  /**
94  * OSGB::Reverse without returning the convergence and scale.
95  **********************************************************************/
96  static void Reverse(double x, double y,
97  [System::Runtime::InteropServices::Out] double% lat,
98  [System::Runtime::InteropServices::Out] double% lon);
99 
100  /**
101  * Convert OSGB coordinates to a grid reference.
102  *
103  * @param[in] x easting of point (meters).
104  * @param[in] y northing of point (meters).
105  * @param[in] prec precision relative to 100 km.
106  * @param[out] gridref National Grid reference.
107  * @exception GeographicErr if \e prec, \e x, or \e y is outside its
108  * allowed range.
109  * @exception std::bad_alloc if the memory for \e gridref can't be
110  * allocatied.
111  *
112  * \e prec specifies the precision of the grid reference string as follows:
113  * - prec = 0 (min), 100km
114  * - prec = 1, 10km
115  * - prec = 2, 1km
116  * - prec = 3, 100m
117  * - prec = 4, 10m
118  * - prec = 5, 1m
119  * - prec = 6, 0.1m
120  * - prec = 11 (max), 1&mu;m
121  *
122  * The easting must be in the range [&minus;1000 km, 1500 km) and the
123  * northing must be in the range [&minus;500 km, 2000 km). These bounds
124  * are consistent with rules for the letter designations for the grid
125  * system.
126  *
127  * If \e x or \e y is NaN, the returned grid reference is "INVALID".
128  **********************************************************************/
129  static void GridReference(double x, double y, int prec,
130  [System::Runtime::InteropServices::Out] System::String^% gridref);
131 
132  /**
133  * Convert OSGB coordinates to a grid reference.
134  *
135  * @param[in] gridref National Grid reference.
136  * @param[out] x easting of point (meters).
137  * @param[out] y northing of point (meters).
138  * @param[out] prec precision relative to 100 km.
139  * @param[in] centerp if true (default), return center of the grid square,
140  * else return SW (lower left) corner.
141  * @exception GeographicErr if \e gridref is illegal.
142  *
143  * The grid reference must be of the form: two letters (not including I)
144  * followed by an even number of digits (up to 22).
145  *
146  * If the first 2 characters of \e gridref are "IN", then \e x and \e y are
147  * set to NaN and \e prec is set to &minus;2.
148  **********************************************************************/
149  static void GridReference(System::String^ gridref,
150  [System::Runtime::InteropServices::Out] double% x,
151  [System::Runtime::InteropServices::Out] double% y,
152  [System::Runtime::InteropServices::Out] int% prec,
153  bool centerp );
154 
155  /** \name Inspector functions
156  **********************************************************************/
157  ///@{
158  /**
159  * @return \e a the equatorial radius of the Airy 1830 ellipsoid (meters).
160  *
161  * This is 20923713 ft converted to meters using the rule 1 ft =
162  * 10<sup>9.48401603&minus;10</sup> m. (The Airy 1830 value is returned
163  * because the OSGB projection is based on this ellipsoid.)
164  **********************************************************************/
165  static double EquatorialRadius();
166 
167  /**
168  * @return \e f the inverse flattening of the Airy 1830 ellipsoid.
169  *
170  * For the Airy 1830 ellipsoid, \e a = 20923713 ft and \e b = 20853810 ft;
171  * thus the flattening = (20923713 &minus; 20853810)/20923713 =
172  * 7767/2324857 = 1/299.32496459... (The Airy 1830 value is returned
173  * because the OSGB projection is based on this ellipsoid.)
174  **********************************************************************/
175  static double Flattening();
176 
177  /**
178  * @return \e k0 central scale for the OSGB projection (0.9996012717).
179  **********************************************************************/
180  static double CentralScale();
181 
182  /**
183  * @return latitude of the origin for the OSGB projection (49 degrees).
184  **********************************************************************/
185  static double OriginLatitude();
186 
187  /**
188  * @return longitude of the origin for the OSGB projection (&minus;2
189  * degrees).
190  **********************************************************************/
191  static double OriginLongitude();
192 
193  /**
194  * @return false northing the OSGB projection (&minus;100000 meters).
195  **********************************************************************/
196  static double FalseNorthing();
197 
198  /**
199  * @return false easting the OSGB projection (400000 meters).
200  **********************************************************************/
201  static double FalseEasting();
202  ///@}
203  };
204 } //
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 double EquatorialRadius()
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)