55 TransverseMercator::TransverseMercator(
Pvl &label,
bool allowDefaults) :
63 if ((allowDefaults) && (!mapGroup.
hasKeyword(
"CenterLongitude"))) {
70 if ((allowDefaults) && (!mapGroup.
hasKeyword(
"CenterLatitude"))) {
81 string msg =
"Invalid Center Latitude Value. Must be between -90 and 90";
87 string msg =
"Invalid Center Longitude Value. Must be between -360 and 360";
119 if ((allowDefaults) && (!mapGroup.
hasKeyword(
"ScaleFactor"))) {
125 string message =
"Invalid label group [Mapping]";
143 if (!Projection::operator==(proj))
return false;
158 return "TransverseMercator";
190 while(deltaLon < -360.0) deltaLon += 360.0;
191 while(deltaLon > 360.0) deltaLon -= 360.0;
192 double deltaLonRads = deltaLon *
PI / 180.0;
204 -
m_e1 * sin(2.0 * latRadians)
205 +
m_e2 * sin(4.0 * latRadians)
206 -
m_e3 * sin(6.0 * latRadians));
209 const double epsilon = 1.0e-10;
214 double cosphi = cos(latRadians);
215 double b = cosphi * sin(deltaLonRads);
218 if (fabs(fabs(b) - 1.0) <= epsilon) {
225 double con = cosphi * cos(deltaLonRads) / sqrt(1.0 - b * b);
226 if (fabs(con) > 1.0) {
238 if (fabs(
HALFPI - fabs(latRadians)) < epsilon) {
244 double sinphi = sin(latRadians);
245 double cosphi = cos(latRadians);
246 double A = cosphi * deltaLonRads;
247 double Asquared = A * A;
248 double C =
m_esp * cosphi * cosphi;
249 double tanphi = tan(latRadians);
250 double T = tanphi * tanphi;
255 * (1.0 + Asquared / 6.0 * (1.0 - T + C + Asquared / 20.0
256 *(5.0 - 18.0*T + T*T + 72.0*C - 58.0*
m_esp)));
258 * (M -
m_ml0 + N*tanphi*(Asquared * (0.5 + Asquared / 24.0 *
259 (5.0 - T + 9.0*C + 4.0*C*C + Asquared / 30.0
260 *(61.0 - 58.0*T + T*T + 600.0*C - 330.0*
m_esp)))));
287 double f, g, h, temp, con, phi, dphi, sinphi, cosphi, tanphi;
288 double c, cs, t, ts, n, rp, d, ds;
289 const double epsilon = 1.0e-10;
294 g = 0.5 * (f - 1.0 / f);
297 con = sqrt((1.0 - h * h) / (1.0 + g * g));
298 if (con > 1.0) con = 1.0;
299 if (con < -1.0) con = -1.0;
303 if (g != 0.0 || h != 0.0) {
312 for (
int i = 1; i < 7; i++) {
313 dphi = ((con +
m_e1 * sin(2.0 * phi) -
m_e2 * sin(4.0 * phi)
314 +
m_e3 * sin(6.0 * phi)) /
m_e0) - phi;
316 if (fabs(dphi) <= epsilon)
break;
320 if (fabs(dphi) > epsilon) {
324 if (fabs(phi) >=
HALFPI) {
333 c =
m_esp * cosphi * cosphi;
337 con = 1.0 -
m_eccsq * sinphi * sinphi;
339 rp = n * (1.0 -
m_eccsq) / con;
342 m_latitude = phi - (n * tanphi * ds / rp) * (0.5 - ds /
343 24.0 * (5.0 + 3.0 * t + 10.0 * c - 4.0 * cs - 9.0 *
344 m_esp - ds / 30.0 * (61.0 + 90.0 * t + 298.0 * c +
345 45.0 * ts - 252.0 *
m_esp - 3.0 * cs)));
354 + (d * (1.0 - ds / 6.0 *
355 (1.0 + 2.0 * t + c - ds / 20.0 * (5.0 - 2.0 * c +
356 28.0 * t - 3.0 * cs + 8.0 *
m_esp + 24.0 * ts))) / cosphi);
401 double &minY,
double &maxY) {
495 bool allowDefaults) {