98 using namespace MSP::CCS;
 
  106 const double PI = 3.14159265358979323e0;
 
  120    double ellipsoidSemiMajorAxis,
 
  121    double ellipsoidFlattening ) :
 
  123   Geocent_e2( 0.0066943799901413800 ),
 
  124   Geocent_ep2( 0.00673949675658690300 )
 
  134   double inv_f = 1 / ellipsoidFlattening;
 
  136   if (ellipsoidSemiMajorAxis <= 0.0)
 
  138   if ((inv_f < 250) || (inv_f > 350))
 
  147   Geocent_ep2 = (1 / (1 - Geocent_e2)) - 1;
 
  150   Geocent_algorithm = UNDEFINED;
 
  158   Geocent_e2    = g.Geocent_e2;
 
  159   Geocent_ep2   = g.Geocent_ep2;
 
  174     Geocent_e2    = g.Geocent_e2;
 
  175     Geocent_ep2   = g.Geocent_ep2;
 
  204   double longitude = geodeticCoordinates->
longitude();
 
  205   double latitude  = geodeticCoordinates->
latitude();
 
  206   double height    = geodeticCoordinates->
height();
 
  212   if ((longitude < -
PI) || (longitude > (2*
PI)))
 
  219   Sin_Lat = sin(latitude);
 
  220   Cos_Lat = cos(latitude);
 
  221   Sin2_Lat = Sin_Lat * Sin_Lat;
 
  223   double X = (Rn + height) * Cos_Lat * cos(longitude);
 
  224   double Y = (Rn + height) * Cos_Lat * sin(longitude);
 
  225   double Z = ((Rn * (1 - Geocent_e2)) + height) * Sin_Lat;
 
  252   double X = cartesianCoordinates->
x();
 
  253   double Y = cartesianCoordinates->
y();
 
  254   double Z = cartesianCoordinates->
z();
 
  255   double latitude, longitude, height;
 
  257   if( Geocent_algorithm == UNDEFINED )
 
  259      Geocent_algorithm = ITERATIVE;
 
  260      char *geotransConv = getenv( 
"MSPCCS_USE_LEGACY_GEOTRANS" );
 
  261      if( geotransConv != NULL )
 
  263         Geocent_algorithm = GEOTRANS;
 
  267   if( Geocent_algorithm == ITERATIVE )
 
  269      geocentricToGeodetic( X, Y, Z, latitude, longitude, height );
 
  292         longitude = atan2(Y,X);
 
  328      S0 = sqrt(T0 * T0 + W2);
 
  331      Sin3_B0 = Sin_B0 * Sin_B0 * Sin_B0;
 
  332      T1 = Z + Geocent_b * Geocent_ep2 * Sin3_B0;
 
  333      Sum = W - 
semiMajorAxis * Geocent_e2 * Cos_B0 * Cos_B0 * Cos_B0;
 
  334      S1 = sqrt(T1*T1 + Sum * Sum);
 
  337      Rn = 
semiMajorAxis / sqrt(1.0 - Geocent_e2 * Sin_p1 * Sin_p1);
 
  340         height = W / Cos_p1 - Rn;
 
  344         height = W / -Cos_p1 - Rn;
 
  348         height = Z / Sin_p1 + Rn * (Geocent_e2 - 1.0);
 
  350      if (At_Pole == 
FALSE)
 
  352         latitude = atan(Sin_p1 / Cos_p1);
 
  360 void Geocentric::geocentricToGeodetic(
 
  369    double eccentricity_squared  = Geocent_e2;
 
  371    double rho, c, s, ct2, e1, e2a;
 
  373    e1 = 1.0 - eccentricity_squared;
 
  374    e2a = eccentricity_squared * equatorial_radius;
 
  376    rho = sqrt(x * x + y * y);
 
  382          ct2 = rho*rho*e1/(e2a*e2a-rho*rho);
 
  383          c = sqrt(ct2 / (1.0 + ct2));
 
  384          s = sqrt(1.0 / (1.0 + ct2));
 
  396       double  ct, new_ct, zabs;
 
  397       double  f, new_f, df_dct, e2;
 
  409          e2 = sqrt(e1 + ct*ct);
 
  411          new_f = rho - zabs*ct - e2a*ct/e2;
 
  413          if (new_f == 0.0) 
break;
 
  415          df_dct = -zabs - (e2a*e1)/(e2*e2*e2);
 
  417          new_ct = ct - new_f / df_dct;
 
  419          if (new_ct < 0.0) new_ct = 0.0;
 
  421       while (fabs(new_f) < fabs(f));
 
  423       s = 1.0 / sqrt(1.0 + ct * ct);
 
  429          lat = -atan(1.0 / ct);
 
  432          lat = atan(1.0 / ct);
 
  438    ht = rho*c + z*s - equatorial_radius*sqrt(1.0 - eccentricity_squared*s*s);