104 using namespace MSP::CCS;
112 const double PI = 3.14159265358979323e0;
125 Mercator::Mercator(
double ellipsoidSemiMajorAxis,
double ellipsoidFlattening,
double centralMeridian,
double standardParallel,
double falseEasting,
double falseNorthing,
double* scaleFactor ) :
128 Merc_e( 0.08181919084262188000 ),
129 Merc_es( 0.0066943799901413800 ),
130 Merc_Cent_Mer( 0.0 ),
131 Merc_Standard_Parallel( 0.0 ),
132 Merc_False_Easting( 0.0 ),
133 Merc_False_Northing( 0.0 ),
134 Merc_Scale_Factor( 1.0 ),
135 Merc_ab( 0.00335655146887969400 ),
136 Merc_bb( 0.00000657187271079536 ),
137 Merc_cb( 0.00000001764564338702 ),
138 Merc_db( 0.00000000005328478445 ),
139 Merc_Delta_Easting( 20237883.0 ),
140 Merc_Delta_Northing( 23421740.0 )
167 double inv_f = 1 / ellipsoidFlattening;
169 if (ellipsoidSemiMajorAxis <= 0.0)
173 if ((inv_f < 250) || (inv_f > 350))
177 if ((standardParallel < -
MAX_LAT) || (standardParallel >
MAX_LAT))
181 if ((centralMeridian < -
PI) || (centralMeridian >
TWO_PI))
189 Merc_Standard_Parallel = standardParallel;
190 if (centralMeridian >
PI)
191 centralMeridian -=
TWO_PI;
192 Merc_Cent_Mer = centralMeridian;
193 Merc_False_Northing = falseNorthing;
194 Merc_False_Easting = falseEasting;
197 Merc_e = sqrt(Merc_es);
198 sin_olat = sin(Merc_Standard_Parallel);
199 Merc_Scale_Factor = cos(Merc_Standard_Parallel) / sqrt(1.e0 - Merc_es * sin_olat * sin_olat );
202 es2 = Merc_es * Merc_es;
205 Merc_ab = Merc_es / 2.e0 + 5.e0 * es2 / 24.e0 + es3 / 12.e0
206 + 13.e0 * es4 / 360.e0;
207 Merc_bb = 7.e0 * es2 / 48.e0 + 29.e0 * es3 / 240.e0
208 + 811.e0 * es4 / 11520.e0;
209 Merc_cb = 7.e0 * es3 / 120.e0 + 81.e0 * es4 / 1120.e0;
210 Merc_db = 4279.e0 * es4 / 161280.e0;
211 *scaleFactor = Merc_Scale_Factor;
220 Merc_Delta_Easting = tempCoordinates->
easting();
221 Merc_Delta_Northing = tempCoordinates->
northing();
222 delete tempCoordinates;
224 if(Merc_False_Easting)
225 Merc_Delta_Easting -= Merc_False_Easting;
226 if (Merc_Delta_Easting < 0)
227 Merc_Delta_Easting = -Merc_Delta_Easting;
228 Merc_Delta_Easting *= 1.01;
230 if(Merc_False_Northing)
231 Merc_Delta_Northing -= Merc_False_Northing;
232 if (Merc_Delta_Northing < 0)
233 Merc_Delta_Northing = -Merc_Delta_Northing;
234 Merc_Delta_Northing *= 1.01;
238 Mercator::Mercator(
double ellipsoidSemiMajorAxis,
double ellipsoidFlattening,
double centralMeridian,
double falseEasting,
double falseNorthing,
double scaleFactor ) :
241 Merc_e( 0.08181919084262188000 ),
242 Merc_es( 0.0066943799901413800 ),
243 Merc_Cent_Mer( 0.0 ),
244 Merc_Standard_Parallel( 0.0 ),
245 Merc_False_Easting( 0.0 ),
246 Merc_False_Northing( 0.0 ),
247 Merc_Scale_Factor( 1.0 ),
248 Merc_ab( 0.00335655146887969400 ),
249 Merc_bb( 0.00000657187271079536 ),
250 Merc_cb( 0.00000001764564338702 ),
251 Merc_db( 0.00000000005328478445 ),
252 Merc_Delta_Easting( 20237883.0 ),
253 Merc_Delta_Northing( 23421740.0 )
277 double Merc_Scale_Factor2;
278 double inv_f = 1 / ellipsoidFlattening;
280 if (ellipsoidSemiMajorAxis <= 0.0)
284 if ((inv_f < 250) || (inv_f > 350))
288 if ((centralMeridian < -
PI) || (centralMeridian >
TWO_PI))
301 if (centralMeridian >
PI)
302 centralMeridian -=
TWO_PI;
303 Merc_Cent_Mer = centralMeridian;
304 Merc_False_Northing = falseNorthing;
305 Merc_False_Easting = falseEasting;
306 Merc_Scale_Factor = scaleFactor;
309 Merc_e = sqrt(Merc_es);
314 es2 = Merc_es * Merc_es;
317 Merc_ab = Merc_es / 2.e0 + 5.e0 * es2 / 24.e0 + es3 / 12.e0
318 + 13.e0 * es4 / 360.e0;
319 Merc_bb = 7.e0 * es2 / 48.e0 + 29.e0 * es3 / 240.e0
320 + 811.e0 * es4 / 11520.e0;
321 Merc_cb = 7.e0 * es3 / 120.e0 + 81.e0 * es4 / 1120.e0;
322 Merc_db = 4279.e0 * es4 / 161280.e0;
325 Merc_Scale_Factor2 = Merc_Scale_Factor * Merc_Scale_Factor;
326 Merc_Standard_Parallel = asin(sqrt((1 - Merc_Scale_Factor2)/(1 - Merc_Scale_Factor2 * Merc_es)));
335 Merc_Delta_Easting = tempCoordinates->
easting();
336 Merc_Delta_Northing = tempCoordinates->
northing();
337 delete tempCoordinates;
339 if(Merc_False_Easting)
340 Merc_Delta_Easting -= Merc_False_Easting;
341 if (Merc_Delta_Easting < 0)
342 Merc_Delta_Easting = -Merc_Delta_Easting;
343 Merc_Delta_Easting *= 1.01;
345 if(Merc_False_Northing)
346 Merc_Delta_Northing -= Merc_False_Northing;
347 if (Merc_Delta_Northing < 0)
348 Merc_Delta_Northing = -Merc_Delta_Northing;
349 Merc_Delta_Northing *= 1.01;
355 coordinateType = m.coordinateType;
360 Merc_Cent_Mer = m.Merc_Cent_Mer;
361 Merc_Standard_Parallel = m.Merc_Standard_Parallel;
362 Merc_False_Easting = m.Merc_False_Easting;
363 Merc_False_Northing = m.Merc_False_Northing;
364 Merc_Scale_Factor = m.Merc_Scale_Factor;
369 Merc_Delta_Easting = m.Merc_Delta_Easting;
370 Merc_Delta_Northing = m.Merc_Delta_Northing;
383 coordinateType = m.coordinateType;
388 Merc_Cent_Mer = m.Merc_Cent_Mer;
389 Merc_Standard_Parallel = m.Merc_Standard_Parallel;
390 Merc_False_Easting = m.Merc_False_Easting;
391 Merc_False_Northing = m.Merc_False_Northing;
392 Merc_Scale_Factor = m.Merc_Scale_Factor;
397 Merc_Delta_Easting = m.Merc_Delta_Easting;
398 Merc_Delta_Northing = m.Merc_Delta_Northing;
471 double longitude = geodeticCoordinates->
longitude();
472 double latitude = geodeticCoordinates->
latitude();
478 if ((longitude < -
PI) || (longitude >
TWO_PI))
485 e_x_sinlat = Merc_e * sin(latitude);
486 tan_temp = tan(
PI / 4.e0 + latitude / 2.e0);
487 pow_temp = pow( ((1.e0 - e_x_sinlat) / (1.e0 + e_x_sinlat)),
489 ctanz2 = tan_temp * pow_temp;
490 double northing = Merc_Scale_Factor *
semiMajorAxis * log(ctanz2) + Merc_False_Northing;
491 Delta_Long = longitude - Merc_Cent_Mer;
494 if (Delta_Long < -
PI)
496 double easting = Merc_Scale_Factor *
semiMajorAxis * Delta_Long
497 + Merc_False_Easting;
522 double easting = mapProjectionCoordinates->
easting();
523 double northing = mapProjectionCoordinates->
northing();
525 if ((easting < (Merc_False_Easting - Merc_Delta_Easting))
526 || (easting > (Merc_False_Easting + Merc_Delta_Easting)))
530 if ((northing < (Merc_False_Northing - Merc_Delta_Northing))
531 || (northing > (Merc_False_Northing + Merc_Delta_Northing)))
536 dy = northing - Merc_False_Northing;
537 dx = easting - Merc_False_Easting;
538 double longitude = Merc_Cent_Mer + dx / (Merc_Scale_Factor *
semiMajorAxis);
540 - 2.e0 * atan(1.e0 / exp(dy / (Merc_Scale_Factor *
semiMajorAxis)));
541 double latitude = xphi + Merc_ab * sin(2.e0 * xphi) + Merc_bb * sin(4.e0 * xphi)
542 + Merc_cb * sin(6.e0 * xphi) + Merc_db * sin(8.e0 * xphi);