public long convertGeodeticToPolarStereographic(double Latitude,double Longitude){
  double dlam;
  double slat;
  double essin;
  double t;
  double rho;
  double pow_es;
  long Error_Code=POLAR_NO_ERROR;
  if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2)) {
    Error_Code|=POLAR_LAT_ERROR;
  }
  if ((Latitude < 0) && (Southern_Hemisphere == 0)) {
    Error_Code|=POLAR_LAT_ERROR;
  }
  if ((Latitude > 0) && (Southern_Hemisphere == 1)) {
    Error_Code|=POLAR_LAT_ERROR;
  }
  if ((Longitude < -PI) || (Longitude > TWO_PI)) {
    Error_Code|=POLAR_LON_ERROR;
  }
  if (Error_Code == POLAR_NO_ERROR) {
    if (Math.abs(Math.abs(Latitude) - PI_OVER_2) < 1.0e-10) {
      Easting=0.0;
      Northing=0.0;
    }
 else {
      if (Southern_Hemisphere != 0) {
        Longitude*=-1.0;
        Latitude*=-1.0;
      }
      dlam=Longitude - Polar_Origin_Long;
      if (dlam > PI) {
        dlam-=TWO_PI;
      }
      if (dlam < -PI) {
        dlam+=TWO_PI;
      }
      slat=Math.sin(Latitude);
      essin=es * slat;
      pow_es=Math.pow((1.0 - essin) / (1.0 + essin),es_OVER_2);
      t=Math.tan(PI_Over_4 - Latitude / 2.0) / pow_es;
      if (Math.abs(Math.abs(Polar_Origin_Lat) - PI_OVER_2) > 1.0e-10)       rho=Polar_a_mc * t / tc;
 else       rho=two_Polar_a * t / e4;
      if (Southern_Hemisphere != 0) {
        Easting=-(rho * Math.sin(dlam) - Polar_False_Easting);
        Northing=rho * Math.cos(dlam) + Polar_False_Northing;
      }
 else       Easting=rho * Math.sin(dlam) + Polar_False_Easting;
      Northing=-rho * Math.cos(dlam) + Polar_False_Northing;
    }
  }
  return (Error_Code);
}

public long convertGeodeticToPolarStereographic ( double Latitude , double Longitude ) { double dlam ; double slat ; double essin ; double t ; double rho ; double pow_es ; long Error_Code = POLAR_NO_ERROR ; if ( ( Latitude < - PI_OVER_2 ) || ( Latitude > PI_OVER_2 ) ) { Error_Code |= POLAR_LAT_ERROR ; } if ( ( Latitude < 0 ) && ( Southern_Hemisphere == 0 ) ) { Error_Code |= POLAR_LAT_ERROR ; } if ( ( Latitude > 0 ) && ( Southern_Hemisphere == 1 ) ) { Error_Code |= POLAR_LAT_ERROR ; } if ( ( Longitude < - PI ) || ( Longitude > TWO_PI ) ) { Error_Code |= POLAR_LON_ERROR ; } if ( Error_Code == POLAR_NO_ERROR ) { if ( Math . abs ( Math . abs ( Latitude ) - PI_OVER_2 ) < 1.0e-10 ) { Easting = 0.0 ; Northing = 0.0 ; } else { if ( Southern_Hemisphere != 0 ) { Longitude *= - 1.0 ; Latitude *= - 1.0 ; } dlam = Longitude - Polar_Origin_Long ; if ( dlam > PI ) { dlam -= TWO_PI ; } if ( dlam < - PI ) { dlam += TWO_PI ; } slat = Math . sin ( Latitude ) ; essin = es * slat ; pow_es = Math . pow ( ( 1.0 - essin ) / ( 1.0 + essin ) , es_OVER_2 ) ; t = Math . tan ( PI_Over_4 - Latitude / 2.0 ) / pow_es ; if ( Math . abs ( Math . abs ( Polar_Origin_Lat ) - PI_OVER_2 ) > 1.0e-10 ) rho = Polar_a_mc * t / tc ; else rho = two_Polar_a * t / e4 ; if ( Southern_Hemisphere != 0 ) { Easting = - ( rho * Math . sin ( dlam ) - Polar_False_Easting ) ; Northing = rho * Math . cos ( dlam ) + Polar_False_Northing ; } else Easting = rho * Math . sin ( dlam ) + Polar_False_Easting ; Northing = - rho * Math . cos ( dlam ) + Polar_False_Northing ; } } return ( Error_Code ) ; }
the function convert_geodetic_to_polar_stereographic converts geodetic coordinates ( latitude and longitude ) to polar stereographic coordinates ( easting and northing ) , according to the current ellipsoid and polar stereographic projection parameters . if any errors occur , error code ( s ) are returned by the function , otherwise polar_no_error is returned .
