NETGeographicLib 1.52
Loading...
Searching...
No Matches
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 * https://geographiclib.sourceforge.io/
11 **********************************************************************/
12
13namespace 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="https://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="https://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="https://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="https://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="https://geographiclib.sourceforge.io/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 EquatorialRadius, 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.
97 * @param[in] k0 central scale factor.
98 * @param[in] extendp use extended domain.
99 * @exception GeographicErr if \e a, \e f, or \e k0 is not positive.
100 *
101 * The transverse Mercator projection has a branch point singularity at \e
102 * lat = 0 and \e lon &minus; \e lon0 = 90 (1 &minus; \e e) or (for
103 * TransverseMercatorExact::UTM) x = 18381 km, y = 0m. The \e extendp
104 * argument governs where the branch cut is placed. With \e extendp =
105 * false, the "standard" convention is followed, namely the cut is placed
106 * along \e x > 18381 km, \e y = 0m. Forward can be called with any \e lat
107 * and \e lon then produces the transformation shown in Lee, Fig 46.
108 * Reverse analytically continues this in the &plusmn; \e x direction. As
109 * a consequence, Reverse may map multiple points to the same geographic
110 * location; for example, for TransverseMercatorExact::UTM, \e x =
111 * 22051449.037349 m, \e y = &minus;7131237.022729 m and \e x =
112 * 29735142.378357 m, \e y = 4235043.607933 m both map to \e lat =
113 * &minus;2&deg;, \e lon = 88&deg;.
114 *
115 * With \e extendp = true, the branch cut is moved to the lower left
116 * quadrant. The various symmetries of the transverse Mercator projection
117 * can be used to explore the projection on any sheet. In this mode the
118 * domains of \e lat, \e lon, \e x, and \e y are restricted to
119 * - the union of
120 * - \e lat in [0, 90] and \e lon &minus; \e lon0 in [0, 90]
121 * - \e lat in (-90, 0] and \e lon &minus; \e lon0 in [90 (1 &minus; \e
122 e), 90]
123 * - the union of
124 * - <i>x</i>/(\e k0 \e a) in [0, &infin;) and
125 * <i>y</i>/(\e k0 \e a) in [0, E(<i>e</i><sup>2</sup>)]
126 * - <i>x</i>/(\e k0 \e a) in [K(1 &minus; <i>e</i><sup>2</sup>) &minus;
127 * E(1 &minus; <i>e</i><sup>2</sup>), &infin;) and <i>y</i>/(\e k0 \e
128 * a) in (&minus;&infin;, 0]
129 * .
130 * See Sec. 5 of
131 * <a href="https://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for a full
132 * discussion of the treatment of the branch cut.
133 *
134 * The method will work for all ellipsoids used in terrestrial geodesy.
135 * The method cannot be applied directly to the case of a sphere (\e f = 0)
136 * because some the constants characterizing this method diverge in that
137 * limit, and in practice, \e f should be larger than about
138 * numeric_limits<double>::epsilon(). However, TransverseMercator treats the
139 * sphere exactly.
140 **********************************************************************/
141 TransverseMercatorExact(double a, double f, double k0, bool extendp );
142
143 /**
144 * The default constructor assumes a WGS84 ellipsoid and a UTM scale
145 * factor.
146 **********************************************************************/
148
149 /**
150 * The destructor calls the finalizer.
151 **********************************************************************/
153 { this->!TransverseMercatorExact(); }
154
155 /**
156 * Forward projection, from geographic to transverse Mercator.
157 *
158 * @param[in] lon0 central meridian of the projection (degrees).
159 * @param[in] lat latitude of point (degrees).
160 * @param[in] lon longitude of point (degrees).
161 * @param[out] x easting of point (meters).
162 * @param[out] y northing of point (meters).
163 * @param[out] gamma meridian convergence at point (degrees).
164 * @param[out] k scale of projection at point.
165 *
166 * No false easting or northing is added. \e lat should be in the range
167 * [&minus;90&deg;, 90&deg;].
168 **********************************************************************/
169 void Forward(double lon0, double lat, double lon,
170 [System::Runtime::InteropServices::Out] double% x,
171 [System::Runtime::InteropServices::Out] double% y,
172 [System::Runtime::InteropServices::Out] double% gamma,
173 [System::Runtime::InteropServices::Out] double% k);
174
175 /**
176 * Reverse projection, from transverse Mercator to geographic.
177 *
178 * @param[in] lon0 central meridian of the projection (degrees).
179 * @param[in] x easting of point (meters).
180 * @param[in] y northing of point (meters).
181 * @param[out] lat latitude of point (degrees).
182 * @param[out] lon longitude of point (degrees).
183 * @param[out] gamma meridian convergence at point (degrees).
184 * @param[out] k scale of projection at point.
185 *
186 * No false easting or northing is added. The value of \e lon returned
187 * is in the range [&minus;180&deg;, 180&deg;).
188 **********************************************************************/
189 void Reverse(double lon0, double x, double y,
190 [System::Runtime::InteropServices::Out] double% lat,
191 [System::Runtime::InteropServices::Out] double% lon,
192 [System::Runtime::InteropServices::Out] double% gamma,
193 [System::Runtime::InteropServices::Out] double% k);
194
195 /**
196 * TransverseMercatorExact::Forward without returning the convergence and
197 * scale.
198 **********************************************************************/
199 void Forward(double lon0, double lat, double lon,
200 [System::Runtime::InteropServices::Out] double% x,
201 [System::Runtime::InteropServices::Out] double% y);
202
203 /**
204 * TransverseMercatorExact::Reverse without returning the convergence and
205 * scale.
206 **********************************************************************/
207 void Reverse(double lon0, double x, double y,
208 [System::Runtime::InteropServices::Out] double% lat,
209 [System::Runtime::InteropServices::Out] double% lon);
210
211 /** \name Inspector functions
212 **********************************************************************/
213 ///@{
214 /**
215 * @return \e a the equatorial radius of the ellipsoid (meters). This is
216 * the value used in the constructor.
217 **********************************************************************/
218 property double EquatorialRadius { double get(); }
219
220 /**
221 * @return \e f the flattening of the ellipsoid. This is the value used in
222 * the constructor.
223 **********************************************************************/
224 property double Flattening { double get(); }
225
226 /**
227 * @return \e k0 central scale for the projection. This is the value of \e
228 * k0 used in the constructor and is the scale on the central meridian.
229 **********************************************************************/
230 property double CentralScale { double get(); }
231 ///@}
232 };
233} // namespace NETGeographicLib
.NET wrapper for GeographicLib::TransverseMercatorExact.
TransverseMercatorExact(double a, double f, double k0, bool extendp)
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 Forward(double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double% x, [System::Runtime::InteropServices::Out] double% y)
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)