public long convertUTMToGeodetic(long Zone,String Hemisphere,double Easting,double Northing){
  long Error_Code=UTM_NO_ERROR;
  double Origin_Latitude=0;
  double False_Easting=500000;
  double False_Northing=0;
  double Scale=0.9996;
  if ((Zone < 1) || (Zone > 60))   Error_Code|=UTM_ZONE_ERROR;
  if (!Hemisphere.equals(AVKey.SOUTH) && !Hemisphere.equals(AVKey.NORTH))   Error_Code|=UTM_HEMISPHERE_ERROR;
  if ((Northing < MIN_NORTHING) || (Northing > MAX_NORTHING))   Error_Code|=UTM_NORTHING_ERROR;
  if (Error_Code == UTM_NO_ERROR) {
    if (Zone >= 31)     Central_Meridian=((6 * Zone - 183) * PI / 180.0);
 else     Central_Meridian=((6 * Zone + 177) * PI / 180.0);
    if (Hemisphere.equals(AVKey.SOUTH))     False_Northing=10000000;
    try {
      TMCoord TM=TMCoord.fromTM(Easting,Northing,Angle.fromRadians(Origin_Latitude),Angle.fromRadians(Central_Meridian),False_Easting,False_Northing,Scale);
      Latitude=TM.getLatitude().radians;
      Longitude=TM.getLongitude().radians;
      if ((Latitude < MIN_LAT) || (Latitude > MAX_LAT)) {
        Error_Code|=UTM_NORTHING_ERROR;
      }
    }
 catch (    Exception e) {
      Error_Code=UTM_TM_ERROR;
    }
  }
  return (Error_Code);
}

public long convertUTMToGeodetic ( long Zone , String Hemisphere , double Easting , double Northing ) { long Error_Code = UTM_NO_ERROR ; double Origin_Latitude = 0 ; double False_Easting = 500000 ; double False_Northing = 0 ; double Scale = 0.9996 ; if ( ( Zone < 1 ) || ( Zone > 60 ) ) Error_Code |= UTM_ZONE_ERROR ; if ( ! Hemisphere . equals ( AVKey . SOUTH ) && ! Hemisphere . equals ( AVKey . NORTH ) ) Error_Code |= UTM_HEMISPHERE_ERROR ; if ( ( Northing < MIN_NORTHING ) || ( Northing > MAX_NORTHING ) ) Error_Code |= UTM_NORTHING_ERROR ; if ( Error_Code == UTM_NO_ERROR ) { if ( Zone >= 31 ) Central_Meridian = ( ( 6 * Zone - 183 ) * PI / 180.0 ) ; else Central_Meridian = ( ( 6 * Zone + 177 ) * PI / 180.0 ) ; if ( Hemisphere . equals ( AVKey . SOUTH ) ) False_Northing = 10000000 ; try { TMCoord TM = TMCoord . fromTM ( Easting , Northing , Angle . fromRadians ( Origin_Latitude ) , Angle . fromRadians ( Central_Meridian ) , False_Easting , False_Northing , Scale ) ; Latitude = TM . getLatitude ( ) . radians ; Longitude = TM . getLongitude ( ) . radians ; if ( ( Latitude < MIN_LAT ) || ( Latitude > MAX_LAT ) ) { Error_Code |= UTM_NORTHING_ERROR ; } } catch ( Exception e ) { Error_Code = UTM_TM_ERROR ; } } return ( Error_Code ) ; }
the function convert_utm_to_geodetic converts utm projection ( zone , 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 utm_no_error is returned .
