101 using namespace MSP::CCS;
 
  109 const double PI = 3.14159265358979323e0;      
 
  120 Mollweide::Mollweide( 
double ellipsoidSemiMajorAxis, 
double ellipsoidFlattening, 
double centralMeridian, 
double falseEasting, 
double falseNorthing ) :
 
  122   es2( 0.0066943799901413800 ),
 
  123   es4( 4.4814723452405e-005 ),
 
  124   es6( 3.0000678794350e-007 ),
 
  125   Sqrt2_Ra( 9009964.7614632 ),
 
  126   Sqrt8_Ra( 18019929.522926 ),
 
  127   Moll_Origin_Long( 0.0 ),
 
  128   Moll_False_Easting( 0.0 ),
 
  129   Moll_False_Northing( 0.0 ),
 
  130   Moll_Delta_Northing( 9009965.0 ),
 
  131   Moll_Max_Easting( 18019930.0 ),
 
  132   Moll_Min_Easting( -18019930.0 )
 
  151   double inv_f = 1 / ellipsoidFlattening;
 
  153   if (ellipsoidSemiMajorAxis <= 0.0)
 
  157   if ((inv_f < 250) || (inv_f > 350))
 
  161   if ((centralMeridian < -
PI) || (centralMeridian > 
TWO_PI))
 
  173   Ra = 
semiMajorAxis * (1.0 - es2 / 6.0 - 17.0 * es4 / 360.0 - 67.0 * es6 / 3024.0);
 
  174   Sqrt2_Ra = sqrt(2.0) * Ra;
 
  175   Sqrt8_Ra = sqrt(8.0) * Ra;
 
  176   if (centralMeridian > 
PI)
 
  177     centralMeridian -= 
TWO_PI;
 
  178   Moll_Origin_Long = centralMeridian;
 
  179   Moll_False_Easting = falseEasting;
 
  180   Moll_False_Northing = falseNorthing;
 
  182   if (Moll_Origin_Long > 0)
 
  184     Moll_Max_Easting = 17919819.0;
 
  185     Moll_Min_Easting = -18019930.0;
 
  187   else if (Moll_Origin_Long < 0)
 
  189     Moll_Max_Easting = 18019930.0;
 
  190     Moll_Min_Easting = -17919819.0;
 
  194     Moll_Max_Easting = 18019930.0;
 
  195     Moll_Min_Easting = -18019930.0;
 
  207   Sqrt2_Ra = m.Sqrt2_Ra;
 
  208   Sqrt8_Ra = m.Sqrt8_Ra;
 
  209   Moll_Origin_Long = m.Moll_Origin_Long;
 
  210   Moll_False_Easting = m.Moll_False_Easting;
 
  211   Moll_False_Northing = m.Moll_False_Northing;
 
  212   Moll_Delta_Northing = m.Moll_Delta_Northing;
 
  213   Moll_Max_Easting = m.Moll_Max_Easting;
 
  214   Moll_Min_Easting = m.Moll_Min_Easting;
 
  232     Sqrt2_Ra = m.Sqrt2_Ra;
 
  233     Sqrt8_Ra = m.Sqrt8_Ra;
 
  234     Moll_Origin_Long = m.Moll_Origin_Long;
 
  235     Moll_False_Easting = m.Moll_False_Easting;
 
  236     Moll_False_Northing = m.Moll_False_Northing;
 
  237     Moll_Delta_Northing = m.Moll_Delta_Northing;
 
  238     Moll_Max_Easting = m.Moll_Max_Easting;
 
  239     Moll_Min_Easting = m.Moll_Min_Easting;
 
  283   double delta_theta_primed = 0.1745329;        
 
  284   double dtp_tolerance = 4.85e-10;              
 
  288   double longitude = geodeticCoordinates->
longitude();
 
  289   double latitude  = geodeticCoordinates->
latitude();
 
  290   double PI_Sin_Latitude = 
PI * sin(latitude);
 
  291   double theta_primed = latitude;
 
  297   if ((longitude < -
PI) || (longitude > 
TWO_PI))
 
  302   dlam = longitude - Moll_Origin_Long;
 
  311   while (fabs(delta_theta_primed) > dtp_tolerance && count)
 
  313     delta_theta_primed = -(theta_primed + sin(theta_primed) -
 
  314                            PI_Sin_Latitude) / (1.0 + cos(theta_primed));
 
  315     theta_primed += delta_theta_primed;
 
  322   theta = theta_primed / 2.0;
 
  323   double easting = (Sqrt8_Ra / 
PI ) * dlam * cos(theta) +
 
  325   double northing = Sqrt2_Ra * sin(theta) + Moll_False_Northing;
 
  350   double longitude, latitude;
 
  352   double easting  = mapProjectionCoordinates->
easting();
 
  353   double northing = mapProjectionCoordinates->
northing();
 
  355   if(   (easting < (Moll_False_Easting + Moll_Min_Easting))
 
  356      || (easting > (Moll_False_Easting + Moll_Max_Easting)))
 
  360   if((northing < (Moll_False_Northing - Moll_Delta_Northing)) || 
 
  361      (northing > (Moll_False_Northing + Moll_Delta_Northing) ))
 
  366   dy = northing - Moll_False_Northing;
 
  367   dx = easting - Moll_False_Easting;
 
  379     two_theta = 2.0 * theta;
 
  380     latitude = asin((two_theta + sin(two_theta)) / 
PI);
 
  388   if (fabs(fabs(latitude) - 
MAX_LAT) < 1.0e-10)
 
  389     longitude = Moll_Origin_Long;
 
  391     longitude = Moll_Origin_Long + 
PI * dx /
 
  392                  (Sqrt8_Ra * cos(theta));
 
  401   else if (longitude < -
PI)