111 using namespace MSP::CCS;
119 const double PI = 3.14159265358979323e0;
130 double albersM(
double clat,
double oneminussqressin )
132 return clat / sqrt(oneminussqressin);
142 double ellipsoidSemiMajorAxis,
143 double ellipsoidFlattening,
144 double centralMeridian,
145 double originLatitude,
146 double standardParallel1,
147 double standardParallel2,
149 double falseNorthing ) :
151 es( 0.08181919084262188000 ),
152 es2( 0.0066943799901413800 ),
153 C( 1.4896626908850 ),
154 rho0( 6388749.3391064 ),
155 n( .70443998701755 ),
156 Albers_a_OVER_n( 9054194.9882824 ),
157 one_MINUS_es2( .99330562000986 ),
158 two_es( .16363838168524 ),
159 Albers_Origin_Long( 0.0 ),
160 Albers_Origin_Lat( (45 *
PI / 180) ),
161 Albers_Std_Parallel_1( 40 *
PI / 180 ),
162 Albers_Std_Parallel_2( 50 *
PI / 180 ),
163 Albers_False_Easting( 0.0 ),
164 Albers_False_Northing( 0.0 ),
165 Albers_Delta_Northing( 40000000 ),
166 Albers_Delta_Easting( 40000000 )
188 double sin_lat, sin_lat_1, cos_lat;
189 double m1, m2, SQRm1;
191 double es_sin, one_MINUS_SQRes_sin;
193 double inv_f = 1 / ellipsoidFlattening;
195 if (ellipsoidSemiMajorAxis <= 0.0)
199 if ((inv_f < 250) || (inv_f > 350))
207 if ((centralMeridian < -
PI) || (centralMeridian >
TWO_PI))
219 if ((standardParallel1 == 0.0) && (standardParallel2 == 0.0))
223 if (standardParallel1 == -standardParallel2)
232 Albers_Origin_Lat = originLatitude;
233 Albers_Std_Parallel_1 = standardParallel1;
234 Albers_Std_Parallel_2 = standardParallel2;
235 if (centralMeridian >
PI)
236 centralMeridian -=
TWO_PI;
237 Albers_Origin_Long = centralMeridian;
238 Albers_False_Easting = falseEasting;
239 Albers_False_Northing = falseNorthing;
243 one_MINUS_es2 = 1 - es2;
246 sin_lat = sin(Albers_Origin_Lat);
247 es_sin = esSine(sin_lat);
249 q0 = albersQ( sin_lat, one_MINUS_SQRes_sin, es_sin );
251 sin_lat_1 = sin(Albers_Std_Parallel_1);
252 cos_lat = cos(Albers_Std_Parallel_1);
253 es_sin = esSine(sin_lat_1);
255 m1 =
albersM( cos_lat, one_MINUS_SQRes_sin );
256 q1 = albersQ( sin_lat_1, one_MINUS_SQRes_sin, es_sin );
259 if (fabs(Albers_Std_Parallel_1 - Albers_Std_Parallel_2) > 1.0e-10)
261 sin_lat = sin(Albers_Std_Parallel_2);
262 cos_lat = cos(Albers_Std_Parallel_2);
263 es_sin = esSine(sin_lat);
265 m2 =
albersM( cos_lat, one_MINUS_SQRes_sin );
266 q2 = albersQ( sin_lat, one_MINUS_SQRes_sin, es_sin );
267 n = (SQRm1 - m2 * m2) / (q2 - q1);
278 rho0 = Albers_a_OVER_n * sqrt(C - nq0);
291 Albers_a_OVER_n = aeac.Albers_a_OVER_n;
292 one_MINUS_es2 = aeac.one_MINUS_es2;
293 two_es = aeac.two_es;
294 Albers_Origin_Long = aeac.Albers_Origin_Long;
295 Albers_Origin_Lat = aeac.Albers_Origin_Lat;
296 Albers_Std_Parallel_1 = aeac.Albers_Std_Parallel_1;
297 Albers_Std_Parallel_2 = aeac.Albers_Std_Parallel_2;
298 Albers_False_Easting = aeac.Albers_False_Easting;
299 Albers_False_Northing = aeac.Albers_False_Northing;
300 Albers_Delta_Northing = aeac.Albers_Delta_Northing;
301 Albers_Delta_Easting = aeac.Albers_Delta_Easting;
322 Albers_a_OVER_n = aeac.Albers_a_OVER_n;
323 one_MINUS_es2 = aeac.one_MINUS_es2;
324 two_es = aeac.two_es;
325 Albers_Origin_Long = aeac.Albers_Origin_Long;
326 Albers_Origin_Lat = aeac.Albers_Origin_Lat;
327 Albers_Std_Parallel_1 = aeac.Albers_Std_Parallel_1;
328 Albers_Std_Parallel_2 = aeac.Albers_Std_Parallel_2;
329 Albers_False_Easting = aeac.Albers_False_Easting;
330 Albers_False_Northing = aeac.Albers_False_Northing;
331 Albers_Delta_Northing = aeac.Albers_Delta_Northing;
332 Albers_Delta_Easting = aeac.Albers_Delta_Easting;
363 Albers_Std_Parallel_1,
364 Albers_Std_Parallel_2,
365 Albers_False_Easting,
366 Albers_False_Northing );
387 double sin_lat, cos_lat;
388 double es_sin, one_MINUS_SQRes_sin;
394 double longitude = geodeticCoordinates->
longitude();
395 double latitude = geodeticCoordinates->
latitude();
401 if ((longitude < -
PI) || (longitude >
TWO_PI))
406 dlam = longitude - Albers_Origin_Long;
415 sin_lat = sin(latitude);
416 cos_lat = cos(latitude);
417 es_sin = esSine( sin_lat );
419 q = albersQ( sin_lat, one_MINUS_SQRes_sin, es_sin );
424 rho = Albers_a_OVER_n * sqrt(C - nq);
428 double easting = rho * sin(theta) + Albers_False_Easting;
429 double northing = rho0 - rho * cos(theta) + Albers_False_Northing;
453 double rho0_MINUS_dy;
454 double q, qconst, q_OVER_2;
456 double PHI, Delta_PHI = 1.0;
458 double es_sin, one_MINUS_SQRes_sin;
461 double longitude, latitude;
462 double tolerance = 4.85e-10;
465 double easting = mapProjectionCoordinates->
easting();
466 double northing = mapProjectionCoordinates->
northing();
468 if( (easting < (Albers_False_Easting - Albers_Delta_Easting))
469 || (easting > Albers_False_Easting + Albers_Delta_Easting))
473 if( (northing < (Albers_False_Northing - Albers_Delta_Northing))
474 || (northing > Albers_False_Northing + Albers_Delta_Northing))
479 dy = northing - Albers_False_Northing;
480 dx = easting - Albers_False_Easting;
481 rho0_MINUS_dy = rho0 - dy;
482 rho = sqrt(dx * dx + rho0_MINUS_dy * rho0_MINUS_dy);
489 rho0_MINUS_dy *= -1.0;
493 theta = atan2(dx, rho0_MINUS_dy);
496 qconst = 1 - ((one_MINUS_es2) / (two_es)) * log((1.0 - es) / (1.0 + es));
497 if (fabs(fabs(qconst) - fabs(q)) > 1.0e-6)
502 else if (q_OVER_2 < -1.0)
506 PHI = asin(q_OVER_2);
511 while ((fabs(Delta_PHI) > tolerance) && count)
514 es_sin = esSine( sin_phi );
517 (one_MINUS_SQRes_sin * one_MINUS_SQRes_sin) / (2.0 * cos(PHI)) *
518 (q / (one_MINUS_es2) - sin_phi / one_MINUS_SQRes_sin +
519 (log((1.0 - es_sin) / (1.0 + es_sin)) / (two_es)));
544 longitude = Albers_Origin_Long + theta / n;
553 else if (longitude < -
PI)
561 double AlbersEqualAreaConic::esSine(
double sinlat )
567 double AlbersEqualAreaConic::albersQ(
568 double slat,
double oneminussqressin,
double essin )
570 return (one_MINUS_es2)*(slat / (oneminussqressin) -
571 (1 / (two_es)) *log((1 - essin) / (1 + essin)));