NETGeographicLib  1.38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
TransverseMercatorExact.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * \file NETGeographicLib/TransverseMercatorExact.h
4  * \brief Header for NETGeographicLib::TransverseMercatorExact class
5  *
6  * NETGeographicLib is copyright (c) Scott Heiman (2013)
7  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
8  * <charles@karney.com> and licensed under the MIT/X11 License.
9  * For more information, see
10  * http://geographiclib.sourceforge.net/
11  **********************************************************************/
12 
13 namespace NETGeographicLib
14 {
15  /**
16  * \brief .NET wrapper for GeographicLib::TransverseMercatorExact.
17  *
18  * This class allows .NET applications to access GeographicLib::TransverseMercatorExact.
19  *
20  * Implementation of the Transverse Mercator Projection given in
21  * - L. P. Lee,
22  * <a href="http://dx.doi.org/10.3138/X687-1574-4325-WM62"> Conformal
23  * Projections Based On Jacobian Elliptic Functions</a>, Part V of
24  * Conformal Projections Based on Elliptic Functions,
25  * (B. V. Gutsell, Toronto, 1976), 128pp.,
26  * ISBN: 0919870163
27  * (also appeared as:
28  * Monograph 16, Suppl. No. 1 to Canadian Cartographer, Vol 13).
29  * - C. F. F. Karney,
30  * <a href="http://dx.doi.org/10.1007/s00190-011-0445-3">
31  * Transverse Mercator with an accuracy of a few nanometers,</a>
32  * J. Geodesy 85(8), 475--485 (Aug. 2011);
33  * preprint
34  * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>.
35  *
36  * Lee gives the correct results for forward and reverse transformations
37  * subject to the branch cut rules (see the description of the \e extendp
38  * argument to the constructor). The maximum error is about 8 nm (8
39  * nanometers), ground distance, for the forward and reverse transformations.
40  * The error in the convergence is 2 &times; 10<sup>&minus;15</sup>&quot;,
41  * the relative error in the scale is 7 &times; 10<sup>&minus;12</sup>%%.
42  * See Sec. 3 of
43  * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for details.
44  * The method is "exact" in the sense that the errors are close to the
45  * round-off limit and that no changes are needed in the algorithms for them
46  * to be used with reals of a higher precision. Thus the errors using long
47  * double (with a 64-bit fraction) are about 2000 times smaller than using
48  * double (with a 53-bit fraction).
49  *
50  * This algorithm is about 4.5 times slower than the 6th-order Kr&uuml;ger
51  * method, TransverseMercator, taking about 11 us for a combined forward and
52  * reverse projection on a 2.66 GHz Intel machine (g++, version 4.3.0, -O3).
53  *
54  * The ellipsoid parameters and the central scale are set in the constructor.
55  * The central meridian (which is a trivial shift of the longitude) is
56  * specified as the \e lon0 argument of the TransverseMercatorExact::Forward
57  * and TransverseMercatorExact::Reverse functions. The latitude of origin is
58  * taken to be the equator. See the documentation on TransverseMercator for
59  * how to include a false easting, false northing, or a latitude of origin.
60  *
61  * See <a href="http://geographiclib.sourceforge.net/tm-grid.kmz"
62  * type="application/vnd.google-earth.kmz"> tm-grid.kmz</a>, for an
63  * illustration of the transverse Mercator grid in Google Earth.
64  *
65  * See GeographicLib::TransverseMercatorExact.cpp for more information on the
66  * implementation.
67  *
68  * See \ref transversemercator for a discussion of this projection.
69  *
70  * C# Example:
71  * \include example-TransverseMercatorExact.cs
72  * Managed C++ Example:
73  * \include example-TransverseMercatorExact.cpp
74  * Visual Basic Example:
75  * \include example-TransverseMercatorExact.vb
76  *
77  * <B>INTERFACE DIFFERENCES:</B><BR>
78  * A default constructor is provided that assumes WGS84 parameters and
79  * a UTM scale factor.
80  *
81  * The MajorRadius, Flattening, and CentralScale functions are
82  * implemented as properties.
83  **********************************************************************/
84  public ref class TransverseMercatorExact
85  {
86  private:
87  // a pointer to the unmanaged GeographicLib::TransverseMercatorExact.
88  GeographicLib::TransverseMercatorExact* m_pTransverseMercatorExact;
89  // the finalizer frees the unmanaged memory when the object is destroyed.
91  public:
92  /**
93  * Constructor for a ellipsoid with
94  *
95  * @param[in] a equatorial radius (meters).
96  * @param[in] f flattening of ellipsoid. If \e f > 1, set flattening
97  * to 1/\e f.
98  * @param[in] k0 central scale factor.
99  * @param[in] extendp use extended domain.
100  * @exception GeographicErr if \e a, \e f, or \e k0 is not positive.
101  *
102  * The transverse Mercator projection has a branch point singularity at \e
103  * lat = 0 and \e lon &minus; \e lon0 = 90 (1 &minus; \e e) or (for
104  * TransverseMercatorExact::UTM) x = 18381 km, y = 0m. The \e extendp
105  * argument governs where the branch cut is placed. With \e extendp =
106  * false, the "standard" convention is followed, namely the cut is placed
107  * along \e x > 18381 km, \e y = 0m. Forward can be called with any \e lat
108  * and \e lon then produces the transformation shown in Lee, Fig 46.
109  * Reverse analytically continues this in the &plusmn; \e x direction. As
110  * a consequence, Reverse may map multiple points to the same geographic
111  * location; for example, for TransverseMercatorExact::UTM, \e x =
112  * 22051449.037349 m, \e y = &minus;7131237.022729 m and \e x =
113  * 29735142.378357 m, \e y = 4235043.607933 m both map to \e lat =
114  * &minus;2&deg;, \e lon = 88&deg;.
115  *
116  * With \e extendp = true, the branch cut is moved to the lower left
117  * quadrant. The various symmetries of the transverse Mercator projection
118  * can be used to explore the projection on any sheet. In this mode the
119  * domains of \e lat, \e lon, \e x, and \e y are restricted to
120  * - the union of
121  * - \e lat in [0, 90] and \e lon &minus; \e lon0 in [0, 90]
122  * - \e lat in (-90, 0] and \e lon &minus; \e lon0 in [90 (1 &minus; \e
123  e), 90]
124  * - the union of
125  * - <i>x</i>/(\e k0 \e a) in [0, &infin;) and
126  * <i>y</i>/(\e k0 \e a) in [0, E(<i>e</i><sup>2</sup>)]
127  * - <i>x</i>/(\e k0 \e a) in [K(1 &minus; <i>e</i><sup>2</sup>) &minus;
128  * E(1 &minus; <i>e</i><sup>2</sup>), &infin;) and <i>y</i>/(\e k0 \e
129  * a) in (&minus;&infin;, 0]
130  * .
131  * See Sec. 5 of
132  * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for a full
133  * discussion of the treatment of the branch cut.
134  *
135  * The method will work for all ellipsoids used in terrestrial geodesy.
136  * The method cannot be applied directly to the case of a sphere (\e f = 0)
137  * because some the constants characterizing this method diverge in that
138  * limit, and in practice, \e f should be larger than about
139  * numeric_limits<double>::epsilon(). However, TransverseMercator treats the
140  * sphere exactly.
141  **********************************************************************/
142  TransverseMercatorExact(double a, double f, double k0, bool extendp );
143 
144  /**
145  * The default constructor assumes a WGS84 ellipsoid and a UTM scale
146  * factor.
147  **********************************************************************/
149 
150  /**
151  * The destructor calls the finalizer.
152  **********************************************************************/
154  { this->!TransverseMercatorExact(); }
155 
156  /**
157  * Forward projection, from geographic to transverse Mercator.
158  *
159  * @param[in] lon0 central meridian of the projection (degrees).
160  * @param[in] lat latitude of point (degrees).
161  * @param[in] lon longitude of point (degrees).
162  * @param[out] x easting of point (meters).
163  * @param[out] y northing of point (meters).
164  * @param[out] gamma meridian convergence at point (degrees).
165  * @param[out] k scale of projection at point.
166  *
167  * No false easting or northing is added. \e lat should be in the range
168  * [&minus;90&deg;, 90&deg;]; \e lon and \e lon0 should be in the
169  * range [&minus;540&deg;, 540&deg;).
170  **********************************************************************/
171  void Forward(double lon0, double lat, double lon,
172  [System::Runtime::InteropServices::Out] double% x,
173  [System::Runtime::InteropServices::Out] double% y,
174  [System::Runtime::InteropServices::Out] double% gamma,
175  [System::Runtime::InteropServices::Out] double% k);
176 
177  /**
178  * Reverse projection, from transverse Mercator to geographic.
179  *
180  * @param[in] lon0 central meridian of the projection (degrees).
181  * @param[in] x easting of point (meters).
182  * @param[in] y northing of point (meters).
183  * @param[out] lat latitude of point (degrees).
184  * @param[out] lon longitude of point (degrees).
185  * @param[out] gamma meridian convergence at point (degrees).
186  * @param[out] k scale of projection at point.
187  *
188  * No false easting or northing is added. \e lon0 should be in the range
189  * [&minus;540&deg;, 540&deg;). The value of \e lon returned is in
190  * the range [&minus;180&deg;, 180&deg;).
191  **********************************************************************/
192  void Reverse(double lon0, double x, double y,
193  [System::Runtime::InteropServices::Out] double% lat,
194  [System::Runtime::InteropServices::Out] double% lon,
195  [System::Runtime::InteropServices::Out] double% gamma,
196  [System::Runtime::InteropServices::Out] double% k);
197 
198  /**
199  * TransverseMercatorExact::Forward without returning the convergence and
200  * scale.
201  **********************************************************************/
202  void Forward(double lon0, double lat, double lon,
203  [System::Runtime::InteropServices::Out] double% x,
204  [System::Runtime::InteropServices::Out] double% y);
205 
206  /**
207  * TransverseMercatorExact::Reverse without returning the convergence and
208  * scale.
209  **********************************************************************/
210  void Reverse(double lon0, double x, double y,
211  [System::Runtime::InteropServices::Out] double% lat,
212  [System::Runtime::InteropServices::Out] double% lon);
213 
214  /** \name Inspector functions
215  **********************************************************************/
216  ///@{
217  /**
218  * @return \e a the equatorial radius of the ellipsoid (meters). This is
219  * the value used in the constructor.
220  **********************************************************************/
221  property double MajorRadius { double get(); }
222 
223  /**
224  * @return \e f the flattening of the ellipsoid. This is the value used in
225  * the constructor.
226  **********************************************************************/
227  property double Flattening { double get(); }
228 
229  /**
230  * @return \e k0 central scale for the projection. This is the value of \e
231  * k0 used in the constructor and is the scale on the central meridian.
232  **********************************************************************/
233  property double CentralScale { double get(); }
234  ///@}
235  };
236 } // namespace NETGeographicLib
void Forward(double lon0, 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)
void Reverse(double lon0, 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)
.NET wrapper for GeographicLib::TransverseMercatorExact.