106 using namespace MSP::CCS;
114 const double PI = 3.14159265358979323e0;
117 const double ONE = (1.0 *
PI / 180);
126 double ellipsoidSemiMajorAxis,
127 double ellipsoidFlattening,
128 double centralMeridian,
129 double originLatitude,
131 double falseNorthing ) :
133 Ra( 6371007.1810824 ),
134 Sin_Azeq_Origin_Lat( 0.0 ),
135 Cos_Azeq_Origin_Lat( 1.0 ),
136 Azeq_Origin_Long( 0.0 ),
137 Azeq_Origin_Lat( 0.0 ),
138 Azeq_False_Easting( 0.0 ),
139 Azeq_False_Northing( 0.0 ),
140 abs_Azeq_Origin_Lat( 0.0 ),
141 Azeq_Delta_Northing( 19903915.0 ),
142 Azeq_Delta_Easting( 19903915.0 )
162 double es2, es4, es6;
163 double inv_f = 1 / ellipsoidFlattening;
165 if (ellipsoidSemiMajorAxis <= 0.0)
169 if ((inv_f < 250) || (inv_f > 350))
177 if ((centralMeridian < -
PI) || (centralMeridian >
TWO_PI))
190 (1.0 - es2 / 6.0 - 17.0 * es4 / 360.0 - 67.0 * es6 / 3024.0);
191 Azeq_Origin_Lat = originLatitude;
192 Sin_Azeq_Origin_Lat = sin(Azeq_Origin_Lat);
193 Cos_Azeq_Origin_Lat = cos(Azeq_Origin_Lat);
194 abs_Azeq_Origin_Lat = fabs(Azeq_Origin_Lat);
195 if (centralMeridian >
PI)
196 centralMeridian -=
TWO_PI;
197 Azeq_Origin_Long = centralMeridian;
198 Azeq_False_Northing = falseNorthing;
199 Azeq_False_Easting = falseEasting;
201 if (fabs(abs_Azeq_Origin_Lat -
PI_OVER_2) < 1.0e-10)
203 Azeq_Delta_Northing = 20015110.0;
204 Azeq_Delta_Easting = 20015110.0;
206 else if (abs_Azeq_Origin_Lat >= 1.0e-10)
208 if (Azeq_Origin_Long > 0.0)
212 Azeq_Delta_Easting = tempCoordinates->
easting();
213 delete tempCoordinates;
219 Azeq_Delta_Easting = tempCoordinates->
easting();
220 delete tempCoordinates;
223 if(Azeq_False_Easting)
224 Azeq_Delta_Easting -= Azeq_False_Easting;
225 if (Azeq_Delta_Easting < 0)
226 Azeq_Delta_Easting = -Azeq_Delta_Easting;
228 Azeq_Delta_Northing = 19903915.0;
232 Azeq_Delta_Northing = 19903915.0;
233 Azeq_Delta_Easting = 19903915.0;
243 Sin_Azeq_Origin_Lat = ae.Sin_Azeq_Origin_Lat;
244 Cos_Azeq_Origin_Lat = ae.Cos_Azeq_Origin_Lat;
245 Azeq_Origin_Long = ae.Azeq_Origin_Long;
246 Azeq_Origin_Lat = ae.Azeq_Origin_Lat;
247 Azeq_False_Easting = ae.Azeq_False_Easting;
248 Azeq_False_Northing = ae.Azeq_False_Northing;
249 abs_Azeq_Origin_Lat = ae.abs_Azeq_Origin_Lat;
250 Azeq_Delta_Northing = ae.Azeq_Delta_Northing;
251 Azeq_Delta_Easting = ae.Azeq_Delta_Easting;
267 Sin_Azeq_Origin_Lat = ae.Sin_Azeq_Origin_Lat;
268 Cos_Azeq_Origin_Lat = ae.Cos_Azeq_Origin_Lat;
269 Azeq_Origin_Long = ae.Azeq_Origin_Long;
270 Azeq_Origin_Lat = ae.Azeq_Origin_Lat;
271 Azeq_False_Easting = ae.Azeq_False_Easting;
272 Azeq_False_Northing = ae.Azeq_False_Northing;
273 abs_Azeq_Origin_Lat = ae.abs_Azeq_Origin_Lat;
274 Azeq_Delta_Northing = ae.Azeq_Delta_Northing;
275 Azeq_Delta_Easting = ae.Azeq_Delta_Easting;
323 double sin_dlam, cos_dlam;
325 double Ra_PI_OVER_2_Lat;
326 double easting, northing;
328 double longitude = geodeticCoordinates->
longitude();
329 double latitude = geodeticCoordinates->
latitude();
330 double slat = sin(latitude);
331 double clat = cos(latitude);
337 if ((longitude < -
PI) || (longitude >
TWO_PI))
342 dlam = longitude - Azeq_Origin_Long;
352 sin_dlam = sin(dlam);
353 cos_dlam = cos(dlam);
354 if (fabs(abs_Azeq_Origin_Lat -
PI_OVER_2) < 1.0e-10)
356 if (Azeq_Origin_Lat >= 0.0)
358 Ra_PI_OVER_2_Lat = Ra * (
PI_OVER_2 - latitude);
359 easting = Ra_PI_OVER_2_Lat * sin_dlam + Azeq_False_Easting;
360 northing = -1.0 * (Ra_PI_OVER_2_Lat * cos_dlam) + Azeq_False_Northing;
364 Ra_PI_OVER_2_Lat = Ra * (
PI_OVER_2 + latitude);
365 easting = Ra_PI_OVER_2_Lat * sin_dlam + Azeq_False_Easting;
366 northing = Ra_PI_OVER_2_Lat * cos_dlam + Azeq_False_Northing;
369 else if (abs_Azeq_Origin_Lat <= 1.0e-10)
371 cos_c = clat * cos_dlam;
372 if (fabs(fabs(cos_c) - 1.0) < 1.0e-14)
376 easting = Azeq_False_Easting;
377 northing = Azeq_False_Northing;
388 k_prime = c / sin(c);
389 Ra_kprime = Ra * k_prime;
390 easting = Ra_kprime * clat * sin_dlam + Azeq_False_Easting;
391 northing = Ra_kprime * slat + Azeq_False_Northing;
396 cos_c = (Sin_Azeq_Origin_Lat * slat) + (Cos_Azeq_Origin_Lat * clat * cos_dlam);
397 if (fabs(fabs(cos_c) - 1.0) < 1.0e-14)
401 easting = Azeq_False_Easting;
402 northing = Azeq_False_Northing;
413 k_prime = c / sin(c);
414 Ra_kprime = Ra * k_prime;
415 easting = Ra_kprime * clat * sin_dlam + Azeq_False_Easting;
416 northing = Ra_kprime * (Cos_Azeq_Origin_Lat * slat - Sin_Azeq_Origin_Lat * clat * cos_dlam) + Azeq_False_Northing;
442 double sin_c, cos_c, dy_sinc;
443 double longitude, latitude;
445 double easting = mapProjectionCoordinates->
easting();
446 double northing = mapProjectionCoordinates->
northing();
448 if ((easting < (Azeq_False_Easting - Azeq_Delta_Easting))
449 || (easting > (Azeq_False_Easting + Azeq_Delta_Easting)))
453 if ((northing < (Azeq_False_Northing - Azeq_Delta_Northing))
454 || (northing > (Azeq_False_Northing + Azeq_Delta_Northing)))
459 dy = northing - Azeq_False_Northing;
460 dx = easting - Azeq_False_Easting;
461 rho = sqrt(dx * dx + dy * dy);
462 if (fabs(rho) <= 1.0e-10)
464 latitude = Azeq_Origin_Lat;
465 longitude = Azeq_Origin_Long;
472 dy_sinc = dy * sin_c;
473 latitude = asin((cos_c * Sin_Azeq_Origin_Lat) + ((dy_sinc * Cos_Azeq_Origin_Lat) / rho));
474 if (fabs(abs_Azeq_Origin_Lat -
PI_OVER_2) < 1.0e-10)
476 if (Azeq_Origin_Lat >= 0.0)
477 longitude = Azeq_Origin_Long + atan2(dx, -dy);
479 longitude = Azeq_Origin_Long + atan2(dx, dy);
482 longitude = Azeq_Origin_Long + atan2((dx * sin_c), ((rho * Cos_Azeq_Origin_Lat * cos_c) - (dy_sinc * Sin_Azeq_Origin_Lat)));
497 else if (longitude < -
PI)