00001 #pragma once 00002 /** 00003 * \file NETGeographicLib/TransverseMercatorExact.h 00004 * \brief Header for NETGeographicLib::TransverseMercatorExact class 00005 * 00006 * NETGeographicLib is copyright (c) Scott Heiman (2013) 00007 * GeographicLib is Copyright (c) Charles Karney (2010-2012) 00008 * <charles@karney.com> and licensed under the MIT/X11 License. 00009 * For more information, see 00010 * http://geographiclib.sourceforge.net/ 00011 **********************************************************************/ 00012 00013 namespace NETGeographicLib 00014 { 00015 /** 00016 * \brief .NET wrapper for GeographicLib::TransverseMercatorExact. 00017 * 00018 * This class allows .NET applications to access GeographicLib::TransverseMercatorExact. 00019 * 00020 * Implementation of the Transverse Mercator Projection given in 00021 * - L. P. Lee, 00022 * <a href="http://dx.doi.org/10.3138/X687-1574-4325-WM62"> Conformal 00023 * Projections Based On Jacobian Elliptic Functions</a>, Part V of 00024 * Conformal Projections Based on Elliptic Functions, 00025 * (B. V. Gutsell, Toronto, 1976), 128pp., 00026 * ISBN: 0919870163 00027 * (also appeared as: 00028 * Monograph 16, Suppl. No. 1 to Canadian Cartographer, Vol 13). 00029 * - C. F. F. Karney, 00030 * <a href="http://dx.doi.org/10.1007/s00190-011-0445-3"> 00031 * Transverse Mercator with an accuracy of a few nanometers,</a> 00032 * J. Geodesy 85(8), 475--485 (Aug. 2011); 00033 * preprint 00034 * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>. 00035 * 00036 * Lee gives the correct results for forward and reverse transformations 00037 * subject to the branch cut rules (see the description of the \e extendp 00038 * argument to the constructor). The maximum error is about 8 nm (8 00039 * nanometers), ground distance, for the forward and reverse transformations. 00040 * The error in the convergence is 2 × 10<sup>−15</sup>", 00041 * the relative error in the scale is 7 × 10<sup>−12</sup>%%. 00042 * See Sec. 3 of 00043 * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for details. 00044 * The method is "exact" in the sense that the errors are close to the 00045 * round-off limit and that no changes are needed in the algorithms for them 00046 * to be used with reals of a higher precision. Thus the errors using long 00047 * double (with a 64-bit fraction) are about 2000 times smaller than using 00048 * double (with a 53-bit fraction). 00049 * 00050 * This algorithm is about 4.5 times slower than the 6th-order Krüger 00051 * method, TransverseMercator, taking about 11 us for a combined forward and 00052 * reverse projection on a 2.66 GHz Intel machine (g++, version 4.3.0, -O3). 00053 * 00054 * The ellipsoid parameters and the central scale are set in the constructor. 00055 * The central meridian (which is a trivial shift of the longitude) is 00056 * specified as the \e lon0 argument of the TransverseMercatorExact::Forward 00057 * and TransverseMercatorExact::Reverse functions. The latitude of origin is 00058 * taken to be the equator. See the documentation on TransverseMercator for 00059 * how to include a false easting, false northing, or a latitude of origin. 00060 * 00061 * See <a href="http://geographiclib.sourceforge.net/tm-grid.kmz" 00062 * type="application/vnd.google-earth.kmz"> tm-grid.kmz</a>, for an 00063 * illustration of the transverse Mercator grid in Google Earth. 00064 * 00065 * See GeographicLib::TransverseMercatorExact.cpp for more information on the 00066 * implementation. 00067 * 00068 * See \ref transversemercator for a discussion of this projection. 00069 * 00070 * C# Example: 00071 * \include example-TransverseMercatorExact.cs 00072 * Managed C++ Example: 00073 * \include example-TransverseMercatorExact.cpp 00074 * Visual Basic Example: 00075 * \include example-TransverseMercatorExact.vb 00076 * 00077 * <B>INTERFACE DIFFERENCES:</B><BR> 00078 * A default constructor is provided that assumes WGS84 parameters and 00079 * a UTM scale factor. 00080 * 00081 * The MajorRadius, Flattening, and CentralScale functions are 00082 * implemented as properties. 00083 **********************************************************************/ 00084 public ref class TransverseMercatorExact 00085 { 00086 private: 00087 // a pointer to the unmanaged GeographicLib::TransverseMercatorExact. 00088 GeographicLib::TransverseMercatorExact* m_pTransverseMercatorExact; 00089 // the finalizer frees the unmanaged memory when the object is destroyed. 00090 !TransverseMercatorExact(void); 00091 public: 00092 /** 00093 * Constructor for a ellipsoid with 00094 * 00095 * @param[in] a equatorial radius (meters). 00096 * @param[in] f flattening of ellipsoid. If \e f > 1, set flattening 00097 * to 1/\e f. 00098 * @param[in] k0 central scale factor. 00099 * @param[in] extendp use extended domain. 00100 * @exception GeographicErr if \e a, \e f, or \e k0 is not positive. 00101 * 00102 * The transverse Mercator projection has a branch point singularity at \e 00103 * lat = 0 and \e lon − \e lon0 = 90 (1 − \e e) or (for 00104 * TransverseMercatorExact::UTM) x = 18381 km, y = 0m. The \e extendp 00105 * argument governs where the branch cut is placed. With \e extendp = 00106 * false, the "standard" convention is followed, namely the cut is placed 00107 * along \e x > 18381 km, \e y = 0m. Forward can be called with any \e lat 00108 * and \e lon then produces the transformation shown in Lee, Fig 46. 00109 * Reverse analytically continues this in the ± \e x direction. As 00110 * a consequence, Reverse may map multiple points to the same geographic 00111 * location; for example, for TransverseMercatorExact::UTM, \e x = 00112 * 22051449.037349 m, \e y = −7131237.022729 m and \e x = 00113 * 29735142.378357 m, \e y = 4235043.607933 m both map to \e lat = 00114 * −2°, \e lon = 88°. 00115 * 00116 * With \e extendp = true, the branch cut is moved to the lower left 00117 * quadrant. The various symmetries of the transverse Mercator projection 00118 * can be used to explore the projection on any sheet. In this mode the 00119 * domains of \e lat, \e lon, \e x, and \e y are restricted to 00120 * - the union of 00121 * - \e lat in [0, 90] and \e lon − \e lon0 in [0, 90] 00122 * - \e lat in (-90, 0] and \e lon − \e lon0 in [90 (1 − \e 00123 e), 90] 00124 * - the union of 00125 * - <i>x</i>/(\e k0 \e a) in [0, ∞) and 00126 * <i>y</i>/(\e k0 \e a) in [0, E(<i>e</i><sup>2</sup>)] 00127 * - <i>x</i>/(\e k0 \e a) in [K(1 − <i>e</i><sup>2</sup>) − 00128 * E(1 − <i>e</i><sup>2</sup>), ∞) and <i>y</i>/(\e k0 \e 00129 * a) in (−∞, 0] 00130 * . 00131 * See Sec. 5 of 00132 * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for a full 00133 * discussion of the treatment of the branch cut. 00134 * 00135 * The method will work for all ellipsoids used in terrestrial geodesy. 00136 * The method cannot be applied directly to the case of a sphere (\e f = 0) 00137 * because some the constants characterizing this method diverge in that 00138 * limit, and in practice, \e f should be larger than about 00139 * numeric_limits<double>::epsilon(). However, TransverseMercator treats the 00140 * sphere exactly. 00141 **********************************************************************/ 00142 TransverseMercatorExact(double a, double f, double k0, bool extendp ); 00143 00144 /** 00145 * The default constructor assumes a WGS84 ellipsoid and a UTM scale 00146 * factor. 00147 **********************************************************************/ 00148 TransverseMercatorExact(); 00149 00150 /** 00151 * The destructor calls the finalizer. 00152 **********************************************************************/ 00153 ~TransverseMercatorExact() 00154 { this->!TransverseMercatorExact(); } 00155 00156 /** 00157 * Forward projection, from geographic to transverse Mercator. 00158 * 00159 * @param[in] lon0 central meridian of the projection (degrees). 00160 * @param[in] lat latitude of point (degrees). 00161 * @param[in] lon longitude of point (degrees). 00162 * @param[out] x easting of point (meters). 00163 * @param[out] y northing of point (meters). 00164 * @param[out] gamma meridian convergence at point (degrees). 00165 * @param[out] k scale of projection at point. 00166 * 00167 * No false easting or northing is added. \e lat should be in the range 00168 * [−90°, 90°]; \e lon and \e lon0 should be in the 00169 * range [−540°, 540°). 00170 **********************************************************************/ 00171 void Forward(double lon0, double lat, double lon, 00172 [System::Runtime::InteropServices::Out] double% x, 00173 [System::Runtime::InteropServices::Out] double% y, 00174 [System::Runtime::InteropServices::Out] double% gamma, 00175 [System::Runtime::InteropServices::Out] double% k); 00176 00177 /** 00178 * Reverse projection, from transverse Mercator to geographic. 00179 * 00180 * @param[in] lon0 central meridian of the projection (degrees). 00181 * @param[in] x easting of point (meters). 00182 * @param[in] y northing of point (meters). 00183 * @param[out] lat latitude of point (degrees). 00184 * @param[out] lon longitude of point (degrees). 00185 * @param[out] gamma meridian convergence at point (degrees). 00186 * @param[out] k scale of projection at point. 00187 * 00188 * No false easting or northing is added. \e lon0 should be in the range 00189 * [−540°, 540°). The value of \e lon returned is in 00190 * the range [−180°, 180°). 00191 **********************************************************************/ 00192 void Reverse(double lon0, double x, double y, 00193 [System::Runtime::InteropServices::Out] double% lat, 00194 [System::Runtime::InteropServices::Out] double% lon, 00195 [System::Runtime::InteropServices::Out] double% gamma, 00196 [System::Runtime::InteropServices::Out] double% k); 00197 00198 /** 00199 * TransverseMercatorExact::Forward without returning the convergence and 00200 * scale. 00201 **********************************************************************/ 00202 void Forward(double lon0, double lat, double lon, 00203 [System::Runtime::InteropServices::Out] double% x, 00204 [System::Runtime::InteropServices::Out] double% y); 00205 00206 /** 00207 * TransverseMercatorExact::Reverse without returning the convergence and 00208 * scale. 00209 **********************************************************************/ 00210 void Reverse(double lon0, double x, double y, 00211 [System::Runtime::InteropServices::Out] double% lat, 00212 [System::Runtime::InteropServices::Out] double% lon); 00213 00214 /** \name Inspector functions 00215 **********************************************************************/ 00216 ///@{ 00217 /** 00218 * @return \e a the equatorial radius of the ellipsoid (meters). This is 00219 * the value used in the constructor. 00220 **********************************************************************/ 00221 property double MajorRadius { double get(); } 00222 00223 /** 00224 * @return \e f the flattening of the ellipsoid. This is the value used in 00225 * the constructor. 00226 **********************************************************************/ 00227 property double Flattening { double get(); } 00228 00229 /** 00230 * @return \e k0 central scale for the projection. This is the value of \e 00231 * k0 used in the constructor and is the scale on the central meridian. 00232 **********************************************************************/ 00233 property double CentralScale { double get(); } 00234 ///@} 00235 }; 00236 } // namespace NETGeographicLib