42# pragma warning (disable: 5055)
54 , _es((_f < 0 ? -1 : 1) * sqrt(fabs(_e2)))
58 , _c( sqrt(_e2m) * exp(
Math::eatanhe(real(1), _es)) )
61 if (!(isfinite(_a) && _a > 0))
63 if (!(isfinite(_f) && _f < 1))
65 if (!(isfinite(_k0) && _k0 > 0))
69#if GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER/2 == 2
70 static const real b1coeff[] = {
74#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER/2 == 3
75 static const real b1coeff[] = {
79#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER/2 == 4
80 static const real b1coeff[] = {
82 25, 64, 256, 4096, 16384, 16384,
85#error "Bad value for GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER"
88#if GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 4
89 static const real alpcoeff[] = {
91 164, 225, -480, 360, 720,
99#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 5
100 static const real alpcoeff[] = {
102 -635, 328, 450, -960, 720, 1440,
104 4496, 3899, -6048, 2730, 10080,
106 15061, -19776, 6832, 26880,
108 -171840, 49561, 161280,
112#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 6
113 static const real alpcoeff[] = {
115 31564, -66675, 34440, 47250, -100800, 75600, 151200,
117 -1983433, 863232, 748608, -1161216, 524160, 1935360,
119 670412, 406647, -533952, 184464, 725760,
121 6601661, -7732800, 2230245, 7257600,
123 -13675556, 3438171, 7983360,
125 212378941, 319334400,
127#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 7
128 static const real alpcoeff[] = {
130 1804025, 2020096, -4267200, 2204160, 3024000, -6451200, 4838400, 9676800,
132 4626384, -9917165, 4316160, 3743040, -5806080, 2620800, 9676800,
134 -67102379, 26816480, 16265880, -21358080, 7378560, 29030400,
136 155912000, 72618271, -85060800, 24532695, 79833600,
138 102508609, -109404448, 27505368, 63866880,
140 -12282192400LL, 2760926233LL, 4151347200LL,
142 1522256789, 1383782400,
144#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 8
145 static const real alpcoeff[] = {
147 -75900428, 37884525, 42422016, -89611200, 46287360, 63504000, -135475200,
148 101606400, 203212800,
150 148003883, 83274912, -178508970, 77690880, 67374720, -104509440,
153 318729724, -738126169, 294981280, 178924680, -234938880, 81164160,
156 -40176129013LL, 14967552000LL, 6971354016LL, -8165836800LL, 2355138720LL,
159 10421654396LL, 3997835751LL, -4266773472LL, 1072709352, 2490808320LL,
161 175214326799LL, -171950693600LL, 38652967262LL, 58118860800LL,
163 -67039739596LL, 13700311101LL, 12454041600LL,
165 1424729850961LL, 743921418240LL,
168#error "Bad value for GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER"
171#if GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 4
172 static const real betcoeff[] = {
174 -4, 555, -960, 720, 1440,
182#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 5
183 static const real betcoeff[] = {
185 -3645, -64, 8880, -15360, 11520, 23040,
187 4416, -3059, 672, 210, 10080,
189 -627, -592, 476, 13440,
195#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 6
196 static const real betcoeff[] = {
198 384796, -382725, -6720, 932400, -1612800, 1209600, 2419200,
200 -1118711, 1695744, -1174656, 258048, 80640, 3870720,
202 22276, -16929, -15984, 12852, 362880,
204 -830251, -158400, 197865, 7257600,
206 -435388, 453717, 15966720,
210#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 7
211 static const real betcoeff[] = {
213 -5406467, 6156736, -6123600, -107520, 14918400, -25804800, 19353600,
216 829456, -5593555, 8478720, -5873280, 1290240, 403200, 19353600,
218 9261899, 3564160, -2708640, -2557440, 2056320, 58060800,
220 14928352, -9132761, -1742400, 2176515, 79833600,
222 -8005831, -1741552, 1814868, 63866880,
224 -261810608, 268433009, 8302694400LL,
226 219941297, 5535129600LL,
228#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 8
229 static const real betcoeff[] = {
231 31777436, -37845269, 43097152, -42865200, -752640, 104428800, -180633600,
232 135475200, 270950400,
234 24749483, 14930208, -100683990, 152616960, -105719040, 23224320, 7257600,
237 -232468668, 101880889, 39205760, -29795040, -28131840, 22619520,
240 324154477, 1433121792, -876745056, -167270400, 208945440, 7664025600LL,
242 457888660, -312227409, -67920528, 70779852, 2490808320LL,
244 -19841813847LL, -3665348512LL, 3758062126LL, 116237721600LL,
246 -1989295244, 1979471673, 49816166400LL,
248 191773887257LL, 3719607091200LL,
251#error "Bad value for GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER"
254 static_assert(
sizeof(b1coeff) /
sizeof(real) == maxpow_/2 + 2,
255 "Coefficient array size mismatch for b1");
256 static_assert(
sizeof(alpcoeff) /
sizeof(real) ==
257 (maxpow_ * (maxpow_ + 3))/2,
258 "Coefficient array size mismatch for alp");
259 static_assert(
sizeof(betcoeff) /
sizeof(real) ==
260 (maxpow_ * (maxpow_ + 3))/2,
261 "Coefficient array size mismatch for bet");
269 for (
int l = 1; l <= maxpow_; ++l) {
271 _alp[l] = d *
Math::polyval(m, alpcoeff + o, _n) / alpcoeff[o + m + 1];
272 _bet[l] = d *
Math::polyval(m, betcoeff + o, _n) / betcoeff[o + m + 1];
355 real& gamma, real& k)
const {
360 latsign = signbit(lat) ? -1 : 1,
361 lonsign = signbit(lon) ? -1 : 1;
370 real sphi, cphi, slam, clam;
395 xip = atan2(taup, clam);
398 etap = asinh(slam / hypot(taup, clam));
403 gamma =
Math::atan2d(slam * taup, clam * hypot(real(1), taup));
411 k = sqrt(_e2m + _e2 *
Math::sq(cphi)) * hypot(real(1), tau)
485 c0 = cos(2 * xip), ch0 = cosh(2 * etap),
486 s0 = sin(2 * xip), sh0 = sinh(2 * etap);
487 complex<real> a(2 * c0 * ch0, -2 * s0 * sh0);
490 y0(n & 1 ? _alp[n] : 0), y1,
491 z0(n & 1 ? 2*n * _alp[n] : 0), z1;
494 y1 = a * y0 - y1 + _alp[n];
495 z1 = a * z0 - z1 + 2*n * _alp[n];
497 y0 = a * y1 - y0 + _alp[n];
498 z0 = a * z1 - z0 + 2*n * _alp[n];
502 z1 = real(1) - z1 + a * z0;
503 a = complex<real>(s0 * ch0, c0 * sh0);
504 y1 = complex<real>(xip, etap) + a * y0;
509 real xi = y1.real(), eta = y1.imag();
510 y = _a1 * _k0 * (backside ?
Math::pi() - xi : xi) * latsign;
511 x = _a1 * _k0 * eta * lonsign;
514 gamma *= latsign * lonsign;
520 real& lat, real& lon,
521 real& gamma, real& k)
const {
526 xi = y / (_a1 * _k0),
527 eta = x / (_a1 * _k0);
530 xisign = signbit(xi) ? -1 : 1,
531 etasign = signbit(eta) ? -1 : 1;
538 c0 = cos(2 * xi), ch0 = cosh(2 * eta),
539 s0 = sin(2 * xi), sh0 = sinh(2 * eta);
540 complex<real> a(2 * c0 * ch0, -2 * s0 * sh0);
543 y0(n & 1 ? -_bet[n] : 0), y1,
544 z0(n & 1 ? -2*n * _bet[n] : 0), z1;
547 y1 = a * y0 - y1 - _bet[n];
548 z1 = a * z0 - z1 - 2*n * _bet[n];
550 y0 = a * y1 - y0 - _bet[n];
551 z0 = a * z1 - z0 - 2*n * _bet[n];
555 z1 = real(1) - z1 + a * z0;
556 a = complex<real>(s0 * ch0, c0 * sh0);
557 y1 = complex<real>(xi, eta) + a * y0;
567 xip = y1.real(), etap = y1.imag(),
569 c = fmax(real(0), cos(xip)),
580 k *= sqrt(_e2m + _e2 / (1 +
Math::sq(tau))) *
581 hypot(real(1), tau) * r;
594 gamma *= xisign * etasign;
Header for GeographicLib::TransverseMercator class.
Exception handling for GeographicLib.
Mathematical functions needed by GeographicLib.
static void sincosd(T x, T &sinx, T &cosx)
static T atan2d(T y, T x)
static T tauf(T taup, T es)
static T AngNormalize(T x)
static T taupf(T tau, T es)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y, T &e)
@ hd
degrees per half turn
@ qd
degrees per quarter turn
Transverse Mercator projection.
void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const
static const TransverseMercator & UTM()
TransverseMercator(real a, real f, real k0)
void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const
Namespace for GeographicLib.