long Convert_UPS_To_Geodetic(char Hemisphere, double Easting, double Northing, double *Latitude, double *Longitude) { /* * The function Convert_UPS_To_Geodetic converts UPS (hemisphere, easting, * and northing) coordinates to geodetic (latitude and longitude) coordinates * according to the current ellipsoid parameters. If any errors occur, the * error code(s) are returned by the function, otherwise UPS_NO_ERROR is * returned. * * Hemisphere : Hemisphere either 'N' or 'S' (input) * Easting : Easting/X in meters (input) * Northing : Northing/Y in meters (input) * Latitude : Latitude in radians (output) * Longitude : Longitude in radians (output) */ long Error_Code = UPS_NO_ERROR; if ((Hemisphere != 'N') && (Hemisphere != 'S')) Error_Code |= UPS_HEMISPHERE_ERROR; if ((Easting < MIN_EAST_NORTH) || (Easting > MAX_EAST_NORTH)) Error_Code |= UPS_EASTING_ERROR; if ((Northing < MIN_EAST_NORTH) || (Northing > MAX_EAST_NORTH)) Error_Code |= UPS_NORTHING_ERROR; if (Hemisphere =='N') {UPS_Origin_Latitude = MAX_ORIGIN_LAT;} if (Hemisphere =='S') {UPS_Origin_Latitude = -MAX_ORIGIN_LAT;} if (!Error_Code) { /* no errors */ Set_Polar_Stereographic_Parameters( UPS_a, UPS_f, UPS_Origin_Latitude, UPS_Origin_Longitude, UPS_False_Easting, UPS_False_Northing); Convert_Polar_Stereographic_To_Geodetic( Easting, Northing, Latitude, Longitude); if ((*Latitude < 0) && (*Latitude > MIN_SOUTH_LAT)) Error_Code |= UPS_LAT_ERROR; if ((*Latitude >= 0) && (*Latitude < MIN_NORTH_LAT)) Error_Code |= UPS_LAT_ERROR; } /* END OF if(!Error_Code) */ return (Error_Code); } /* END OF Convert_UPS_To_Geodetic */
rspfGpt rspfPolarStereoProjection::inverse_do(const rspfDpt &eastingNorthing,const rspfGpt &latLon)const { double lat = 0.0; double lon = 0.0; Convert_Polar_Stereographic_To_Geodetic(eastingNorthing.x, eastingNorthing.y, &lat, &lon); return rspfGpt(lat*DEG_PER_RAD, lon*DEG_PER_RAD, 0.0, theDatum); }